[pgAdmin4][PATCH] Fix handling of real type

2017-06-19 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the handling of  real type.
RM#2502

Steps to re-produce: Below given query fails to render result in Query tool,
SELECT 'Infinity'::real, '{Infinity}'::real[]

Also updated PG Data type feature test for the same.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py 
b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
index b883aac..b8e0959 100644
--- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py
+++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
@@ -90,14 +90,16 @@ class PGDataypeFeatureTest(BaseFeatureTest):
 "922337203685.4775807::decimal, 92203685.477::decimal," \
 "922337203685.922337203685::numeric, " \
 "-92233720368547758.08::numeric," \
-"ARRAY[1, 2, 3]::float[], ARRAY['nan', 'nan', 'nan']::float[];"
+"ARRAY[1, 2, 3]::float[], ARRAY['nan', 'nan', 
'nan']::float[]," \
+"'Infinity'::real, '{Infinity}'::real[];"
 
 expected_output = [
 '-32767', '32767', '-2147483647', '2147483647',
 '9223372036854775807', '9223372036854775807',
 '922337203685.4775807', '92203685.477',
 '922337203685.922337203685', '-92233720368547758.08',
-'{1,2,3}', '{NaN,NaN,NaN}'
+'{1,2,3}', '{NaN,NaN,NaN}',
+'Infinity', '{Infinity}'
 ]
 
 self.page.driver.find_element_by_link_text("Tools").click()
@@ -133,10 +135,17 @@ class PGDataypeFeatureTest(BaseFeatureTest):
 cnt = 12
 for val in expected_output[10:]:
 try:
-source_code = self.page.find_by_xpath(
-"//*[@id='0']//*[@id='datagrid']/div[5]/div/div/div["
-+ str(cnt)
+if cnt == 14:
+xpath = 
"//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[" \
++ str(cnt) \
++ "]/span"
+else:
+xpath = 
"//*[@id='0']//*[@id='datagrid']/div[5]/div/div/div[" \
++ str(cnt) \
 + "]"
+
+source_code = self.page.find_by_xpath(
+ xpath
 ).get_attribute('innerHTML')
 
 PGDataypeFeatureTest.check_result(
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py 
b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 92562bc..0e110b7 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -70,8 +70,8 @@ psycopg2.extensions.register_type(
 # date, timestamp, timestamptz, bigint, double precision, bigint[]
 1700, 1082, 1114, 1184, 20, 701, 1016,
 
-# double precision[]
-1022
+# double precision[], real, real[]
+1022, 700, 1021
  ),
 'TYPECAST_TO_STRING', psycopg2.STRING)
 )


[pgAdmin4][PATCH] Fix clicking on the "pgAdmin 4" header logo shows a empty dialog

2017-06-19 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue, where user will get empty dialog in
desktop mode if user clicks on pgadmin4 header logo. pgAdmin4 is already a
SPA so in my opinion we don't require route to to home page.
RM#2479

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/index.html 
b/web/pgadmin/browser/templates/browser/index.html
index 92950fd..63d696f 100644
--- a/web/pgadmin/browser/templates/browser/index.html
+++ b/web/pgadmin/browser/templates/browser/index.html
@@ -88,6 +88,9 @@ require.onResourceLoad = function (context, map, depMaps) {
   text-align: center;
   color: #fff;
 }
+.pgadmin_header_logo {
+  cursor: default;
+}
 
 
   
@@ -104,7 +107,7 @@ require.onResourceLoad = function (context, map, depMaps) {
 
 
 
-
+
 
  {{ config.APP_NAME }}
 


Re: [pgAdmin4][PATCH] Fix handling of real type

2017-06-20 Thread Murtuza Zabuawala
Hi,

Please ignore previous patch, Attach is the updated patch which will cover

RM#2498 -  Handling of  bytea[] type.
RM#2502 -  Handling of  real & real[] type.

including their feature tests.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Mon, Jun 19, 2017 at 9:58 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix the handling of  real type.
> RM#2502
>
> Steps to re-produce: Below given query fails to render result in Query
> tool,
> SELECT 'Infinity'::real, '{Infinity}'::real[]
>
> Also updated PG Data type feature test for the same.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py 
b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
index b883aac..dff5c48 100644
--- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py
+++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
@@ -80,24 +80,26 @@ class PGDataypeFeatureTest(BaseFeatureTest):
 self.page.toggle_open_tree_item(self.server['name'])
 self.page.toggle_open_tree_item('Databases')
 self.page.toggle_open_tree_item('acceptance_test_db')
-self.page.toggle_open_tree_item('Schemas')
-self.page.toggle_open_tree_item('public')
 
 def _check_datatype(self):
-query = "SELECT -32767::smallint, 32767::smallint," \
-"-2147483647::integer, 2147483647::integer," \
-"9223372036854775807::bigint, 9223372036854775807::bigint," \
-"922337203685.4775807::decimal, 92203685.477::decimal," \
-"922337203685.922337203685::numeric, " \
-"-92233720368547758.08::numeric," \
-"ARRAY[1, 2, 3]::float[], ARRAY['nan', 'nan', 'nan']::float[];"
+query = r"SELECT -32767::smallint, 32767::smallint," \
+r"-2147483647::integer, 2147483647::integer," \
+r"9223372036854775807::bigint, 9223372036854775807::bigint," \
+r"922337203685.4775807::decimal, 92203685.477::decimal," \
+r"922337203685.922337203685::numeric, " \
+r"-92233720368547758.08::numeric," \
+r"ARRAY[1, 2, 3]::float[], ARRAY['nan', 'nan', 
'nan']::float[]," \
+r"'Infinity'::real, '{Infinity}'::real[]," \
+r"E'\\xDEADBEEF'::bytea, ARRAY[E'\\xDEADBEEF', 
E'\\xDEADBEEF']::bytea[];"
 
 expected_output = [
 '-32767', '32767', '-2147483647', '2147483647',
 '9223372036854775807', '9223372036854775807',
 '922337203685.4775807', '92203685.477',
 '922337203685.922337203685', '-92233720368547758.08',
-'{1,2,3}', '{NaN,NaN,NaN}'
+'{1,2,3}', '{NaN,NaN,NaN}',
+'Infinity', '{Infinity}',
+r'\336\255\276\357', 
r'{"\\336\\255\\276\\357","\\336\\255\\276\\357"}'
 ]
 
 self.page.driver.find_element_by_link_text("Tools").click()
@@ -133,10 +135,17 @@ class PGDataypeFeatureTest(BaseFeatureTest):
 cnt = 12
 for val in expected_output[10:]:
 try:
-source_code = self.page.find_by_xpath(
-"//*[@id='0']//*[@id='datagrid']/div[5]/div/div/div["
-+ str(cnt)
+if cnt == 14:
+xpath = 
"//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[" \
++ str(cnt) \
++ "]/span"
+else:
+xpath = 
"//*[@id='0']//*[@id='datagrid']/div[5]/div/div/div[" \
++ str(cnt) \
 + "]"
+
+source_code = self.page.find_by_xpath(
+ xpath
 ).get_attribute('innerHTML')
 
 PGDataypeFeatureTest.check_result(
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py 
b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 92562bc..876b887 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -60,8 +60,8 @@ psycopg2.extensions.register_type(
 psycopg2.extensions.register_type(
 psycopg2.extensions.new_type(
 (
-# To cast bytea and interval type
-17, 1186,
+# To cast bytea, bytea[] and interval type
+17, 1001, 1186,
 
 # to cast int4range, int8range, numrange tsrange, tstzrange,
 # daterange
@@ -70,8 +70,8 @@ psycopg2.extensions.register_type(
 # date, timestamp, timestamptz, bigint, double precision, bigint[]
 1700, 1082, 1114, 1184, 20, 701, 1016,
 
-# double precision[]
-1022
+# double precision[], real, real[]
+1022, 700, 1021
  ),
 'TYPECAST_TO_STRING', psycopg2.STRING)
 )


[pgAdmin4][PATCH] To increase the size of Grant Wizard dialog

2017-06-20 Thread Murtuza Zabuawala
Hi,

PFA minor patch to make Grant Wizard dialog size larger so that it displays
all the privileges properly when opened in smaller resolution screen.
RM#2013

Tested on 1024 x 768 screen resolution.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js 
b/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js
index f79fb2f..ebba51b 100644
--- a/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js
+++ b/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js
@@ -1121,7 +1121,7 @@ define([
 }
 
 // Call Grant Wizard Dialog and set dimensions for wizard
-alertify.wizardDialog(true).resizeTo('40%', '60%');
+alertify.wizardDialog(true).resizeTo('55%', '75%');
   }
 };
 


[pgAdmin4][PATCH] To fix the issue in Synonym node

2017-06-20 Thread Murtuza Zabuawala
Hi,

PFA patch to handle the deleted Synonym node gracefully when user clicks
SQL or Properties Panel.
RM#2503

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
index 50fd219..e49ab43 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
@@ -334,18 +334,28 @@ class SynonymView(PGChildNodeView):
 except ValueError:
 data[k] = v
 
-sql = render_template("/".join([self.template_path,
-'get_objects.sql']),
-  trgTyp=data['trgTyp'],
-  trgSchema=data['trgSchema'])
-status, rset = self.conn.execute_dict(sql)
+is_valid_request = True
+if 'trgTyp' not in data or data['trgTyp'] is None or \
+data['trgTyp'].strip() == '':
+is_valid_request = False
+
+if 'trgSchema' not in data or data['trgSchema'] is None or \
+data['trgSchema'].strip() == '':
+is_valid_request = False
+
+if is_valid_request:
+sql = render_template("/".join([self.template_path,
+'get_objects.sql']),
+trgTyp=data['trgTyp'],
+trgSchema=data['trgSchema'])
+status, rset = self.conn.execute_dict(sql)
 
-if not status:
-return internal_server_error(errormsg=rset)
+if not status:
+return internal_server_error(errormsg=rset)
 
-for row in rset['rows']:
-res.append({'label': row['name'],
-'value': row['name']})
+for row in rset['rows']:
+res.append({'label': row['name'],
+'value': row['name']})
 
 return make_json_response(
 data=res,
@@ -384,14 +394,8 @@ class SynonymView(PGChildNodeView):
 status=200
 )
 else:
-return make_json_response(
-success=410,
-errormsg=gettext(
-'Error: Object not found.'
-),
-info=gettext(
-'The specified synonym could not be found.\n'
-)
+return gone(
+gettext('The specified synonym could not be found.')
 )
 
 except Exception as e:
@@ -483,14 +487,8 @@ class SynonymView(PGChildNodeView):
 if len(res['rows']) > 0:
 data = res['rows'][0]
 else:
-return make_json_response(
-success=0,
-errormsg=gettext(
-'Error: Object not found.'
-),
-info=gettext(
-'The specified synonym could not be found.\n'
-)
+return gone(
+gettext('The specified synonym could not be found.')
 )
 
 SQL = render_template("/".join([self.template_path,
@@ -646,14 +644,8 @@ class SynonymView(PGChildNodeView):
 if len(res['rows']) > 0:
data = res['rows'][0]
 else:
-return make_json_response(
-success=0,
-errormsg=gettext(
-'Error: Object not found.'
-),
-info=gettext(
-'The specified synonym could not be found.\n'
-)
+return gone(
+gettext('The specified synonym could not be found.')
 )
 
 SQL = render_template("/".join([self.template_path,


[pgAdmin4][PATCH] To fix the issue in Materialized View

2017-06-21 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where create dialog opens blank due to JS
error.
RM#2504

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
index 4fafcca..47ff649 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
@@ -173,7 +173,7 @@ define('pgadmin.node.mview', [
 },{
   id: 'fillfactor', label: gettext('Fill Factor'),
   group: gettext('Storage'), mode: ['edit', 'create'],
-  type: 'integer'
+  type: 'numeric'
 },{
   type: 'nested', control: 'tab', id: 'materialization',
   label: gettext('Parameter'), mode: ['edit', 'create'],


Re: [pgAdmin4][PATCH] To fix the issue in Materialized View

2017-06-21 Thread Murtuza Zabuawala
Hi,

Please ignore previous patch.

Attached is the updated patch which includes fixes for Materialized View &
pgAgent modules are also included.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jun 21, 2017 at 1:54 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA minor patch to fix the issue where create dialog opens blank due to JS
> error.
> RM#2504
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
index 4fafcca..7e1c835 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
@@ -173,7 +173,7 @@ define('pgadmin.node.mview', [
 },{
   id: 'fillfactor', label: gettext('Fill Factor'),
   group: gettext('Storage'), mode: ['edit', 'create'],
-  type: 'integer'
+  type: 'int'
 },{
   type: 'nested', control: 'tab', id: 'materialization',
   label: gettext('Parameter'), mode: ['edit', 'create'],
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
index f92c5b1..df6d98e 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
@@ -251,7 +251,7 @@ define('pgadmin.node.pga_schedule', [
   return pgBrowser.Node.Model.prototype.parse.apply(this, arguments);
 },
 schema: [{
-  id: 'jscid', label: gettext('ID'), type: 'integer',
+  id: 'jscid', label: gettext('ID'), type: 'int',
   cellHeaderClasses: 'width_percent_5', mode: ['properties']
 },{
   id: 'jscname', label: gettext('Name'), type: 'text',
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
index 7e676a3..baabda6 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
@@ -90,7 +90,7 @@ define('pgadmin.node.pga_jobstep', [
 },
 idAttribute: 'jstid',
 schema: [{
-  id: 'jstid', label: gettext('ID'), type: 'integer',
+  id: 'jstid', label: gettext('ID'), type: 'int',
   cellHeaderClasses: 'width_percent_5', mode: ['properties']
 },{
   id: 'jstname', label: gettext('Name'), type: 'text',


Re: [pgAdmin4][PATCH] To fix the issue in Materialized View

2017-06-21 Thread Murtuza Zabuawala
Apologies disregard my previous patch also,

I missed changes in "pga_job.js".

Thanks to Harshal pointing that out.



--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jun 21, 2017 at 3:44 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> Please ignore previous patch.
>
> Attached is the updated patch which includes fixes for Materialized View &
> pgAgent modules are also included.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Jun 21, 2017 at 1:54 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA minor patch to fix the issue where create dialog opens blank due to
>> JS error.
>> RM#2504
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
index 4fafcca..7e1c835 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/js/mview.js
@@ -173,7 +173,7 @@ define('pgadmin.node.mview', [
 },{
   id: 'fillfactor', label: gettext('Fill Factor'),
   group: gettext('Storage'), mode: ['edit', 'create'],
-  type: 'integer'
+  type: 'int'
 },{
   type: 'nested', control: 'tab', id: 'materialization',
   label: gettext('Parameter'), mode: ['edit', 'create'],
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
index f92c5b1..df6d98e 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/js/pga_schedule.js
@@ -251,7 +251,7 @@ define('pgadmin.node.pga_schedule', [
   return pgBrowser.Node.Model.prototype.parse.apply(this, arguments);
 },
 schema: [{
-  id: 'jscid', label: gettext('ID'), type: 'integer',
+  id: 'jscid', label: gettext('ID'), type: 'int',
   cellHeaderClasses: 'width_percent_5', mode: ['properties']
 },{
   id: 'jscname', label: gettext('Name'), type: 'text',
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
index 7e676a3..baabda6 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
@@ -90,7 +90,7 @@ define('pgadmin.node.pga_jobstep', [
 },
 idAttribute: 'jstid',
 schema: [{
-  id: 'jstid', label: gettext('ID'), type: 'integer',
+  id: 'jstid', label: gettext('ID'), type: 'int',
   cellHeaderClasses: 'width_percent_5', mode: ['properties']
 },{
   id: 'jstname', label: gettext('Name'), type: 'text',
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_job/js/pga_job.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_job/js/pga_job.js
index 9702bec..ea1f118 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_job/js/pga_job.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_job/js/pga_job.js
@@ -97,7 +97,7 @@ define('pgadmin.node.pga_job', [
   id: 'jobclass', label: gettext('Job class'), type: 'text',
   mode: ['properties']
 },{
-  id: 'jobjclid', label: gettext('Job class'), type: 'integer',
+  id: 'jobjclid', label: gettext('Job class'), type: 'int',
   control: 'node-ajax-options', url: 'classes', url_with_id: false,
   cache_node: 'server', mode: ['create', 'edit'],
   select2: {allowClear: false},


[pgAdmin4][PATCH] To fix the issue in column module

2017-06-22 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where in column node we were not displaying
column's default value properly, for example if the default value is zero.
RM#1860

I have also fixed similar issue in foreign table module.

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql
index d055de0..e751c7f 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql
@@ -8,7 +8,7 @@ CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) 
}}(
 {% for o in c.coloptions %}{% if o.option and o.value %}
 {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif 
%}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
 {% endfor %}{% endif %}{% if c.attnotnull %}
- NOT NULL{% else %} NULL{% endif %}{% if c.typdefault %}
+ NOT NULL{% else %} NULL{% endif %}{% if c.typdefault is defined and 
c.typdefault is not none %}
  DEFAULT {{c.typdefault}}{% endif %}{% if c.collname %}
  COLLATE {{c.collname}}{% endif %}
 {% if not loop.last %},
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql
index 8b85b90..ae01782 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql
@@ -29,7 +29,7 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
 {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif 
%}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
 {% endfor %}{% endif %}
 {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %}
-{% if c.typdefault %} DEFAULT {{c.typdefault}}{% endif %}
+{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT 
{{c.typdefault}}{% endif %}
 {% if c.collname %} COLLATE {{c.collname}}{% endif %};
 {% endfor -%}
 {% for c in data.columns.changed %}
@@ -51,10 +51,10 @@ c.precision != o_data['columns'][c.attnum]['precision'] %}
 ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
 ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ 
conn|qtTypeIdent(c.datatype) }}{% if c.typlen %}({{c.typlen}}{% if c.precision 
%}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %};
 {% endif %}
-{% if c.typdefault != o_data['columns'][c.attnum]['typdefault'] %}
+{% if c.typdefault is defined and c.typdefault != 
o_data['columns'][c.attnum]['typdefault'] %}
 
 ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
-ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault %} SET DEFAULT 
{{c.typdefault}}{% else %} DROP DEFAULT{% endif %};
+ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and 
c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% 
endif %};
 {% endif %}
 {% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %}
 
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql
index bccebd4..59250fe 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql
@@ -12,7 +12,7 @@ CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) 
}}(
 {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif 
%}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %}
 {% endfor %}{% endif %}
 {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %}
-{% if c.typdefault %} DEFAULT {{c.typdefault}}{% endif %}
+{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT 
{{c.typdefault}}{% endif %}
 {% if c.collname %} COLLATE {{c.collname}}{% endif %}
 {% if not loop.last %},
 {% endif %}
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/upda

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

2017-06-22 Thread Murtuza Zabuawala
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
>
>


[pgAdmin4][Patch] To fix the in Import/Export module

2017-06-22 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue in import/export module where,
1) Command was failing due to incorrect tab delimiter passed to the copy
command.
2) User was not allowed to pass default delimiter(ie - no delimiter, let
copy command handle it) for csv & text file format user was forced to
select delimiter.
RM#1934

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js 
b/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js
index a8eac3c..8eebac5 100644
--- 
a/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js
+++ 
b/web/pgadmin/tools/import_export/templates/import_export/js/import_export.js
@@ -23,7 +23,7 @@ define([
   encoding: undefined,
   oid: undefined,
   header: undefined,
-  delimiter: ';',
+  delimiter: '',
   quote: '\"',
   escape: '\'',
   null_string: undefined,
@@ -490,8 +490,8 @@ define([
 this.view.model.on('change', function() {
 if (!_.isUndefined(this.get('filename')) && 
this.get('filename') !== '') {
   this.errorModel.clear();
-  if (!_.isUndefined(this.get('delimiter')) && 
this.get('delimiter') !== '' &&
-  (this.get('delimiter').length == 1 || 
this.get('delimiter') == '[tab]')) {
+  if (!_.isUndefined(this.get('delimiter')) && 
!_.isNull(this.get('delimiter'))
+  ) {
 this.errorModel.clear();
 if (!_.isUndefined(this.get('quote')) && 
this.get('quote') !== '' &&
 this.get('quote').length == 1) {
diff --git 
a/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql 
b/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql
index 16de8c5..4936d65 100644
--- a/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql
+++ b/web/pgadmin/tools/import_export/templates/import_export/sql/cmd.sql
@@ -1 +1 @@
-\copy {{ conn|qtIdent(data.schema, data.table) }} {% if columns %} {{ columns 
}} {% endif %} {% if data.is_import %}FROM{% else %}TO{% endif %} {{ 
data.filename|qtLiteral }} {% if data.oid %} OIDS {% endif %}{% if 
data.delimiter and data.format != 'binary' and data.delimiter == '[tab]' %} 
DELIMITER E'\\t' {% elif data.format != 'binary' and data.delimiter %} 
DELIMITER {{ data.delimiter|qtLiteral }}{% endif %}{% if data.format == 'csv' 
%} CSV {% endif %} {% if data.header %} HEADER {% endif %}{% if data.encoding 
%} ENCODING {{ data.encoding|qtLiteral }}{% endif %}{% if data.format == 'csv' 
and data.quote %} QUOTE {{ data.quote|qtLiteral }}{% endif %}{% if data.format 
!= 'binary' and data.null_string %} NULL {{ data.null_string|qtLiteral }}{% 
endif %}{% if data.format == 'csv' and data.escape %} ESCAPE {{ 
data.escape|qtLiteral }}{% endif %}{% if data.format == 'csv' and 
data.is_import and ignore_column_list %} FORCE_NOT_NULL {{ ignore_column_list 
}} {% endif %};
+\copy {{ conn|qtIdent(data.schema, data.table) }} {% if columns %} {{ columns 
}} {% endif %} {% if data.is_import %}FROM{% else %}TO{% endif %} {{ 
data.filename|qtLiteral }} {% if data.oid %} OIDS {% endif %}{% if 
data.delimiter is defined and data.delimiter == '' and (data.format == 'csv' or 
data.format == 'text') %} {% elif data.delimiter and data.format != 'binary' 
and data.delimiter == '[tab]' %} DELIMITER E'\t' {% elif data.format != 
'binary' and data.delimiter %} DELIMITER {{ data.delimiter|qtLiteral }}{% endif 
%}{% if data.format == 'csv' %} CSV {% endif %} {% if data.header %} HEADER {% 
endif %}{% if data.encoding %} ENCODING {{ data.encoding|qtLiteral }}{% endif 
%}{% if data.format == 'csv' and data.quote %} QUOTE {{ data.quote|qtLiteral 
}}{% endif %}{% if data.format != 'binary' and data.null_string %} NULL {{ 
data.null_string|qtLiteral }}{% endif %}{% if data.format == 'csv' and 
data.escape %} ESCAPE {{ data.escape|qtLiteral }}{% endif %}{% if data.format 
== 'csv' and data.is_import and ignore_column_list %} FORCE_NOT_NULL {{ 
ignore_column_list }} {% endif %};


[pgAdmin4][Patch] To fix the issue in Column module

2017-06-22 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue in Column module where clearing the length of a
character(or any other type as well) generates empty SQL.
RM#2155

--
Regards,
Murtuza Zabuawala
EnterpriseDB: 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/update.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql
index 2fef3b4..385e40e 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 and 
data.attlen != o_data.attlen) or (data.attprecision 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) %}
 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 fe2c73e..6b17481 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 and 
data.attlen != o_data.attlen) or (data.attprecision 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) %}
 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 %};


[pgAdmin4][Patch] To fix the issue in Debugger module

2017-06-22 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue in Debugger module where it was unable to start
debugging if 'plugin_debugger' can not found in shared_preload_libraries.
RM#2162

Original patch by: Kit Yam Tse <https://redmine.postgresql.org/users/382>
(who reported the issue)

I just re-based it against current code.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/debugger/__init__.py 
b/web/pgadmin/tools/debugger/__init__.py
index 79e5eae..22df207 100644
--- a/web/pgadmin/tools/debugger/__init__.py
+++ b/web/pgadmin/tools/debugger/__init__.py
@@ -207,17 +207,6 @@ def init_function(node_type, sid, did, scid, fid, 
trid=None):
 " and cannot be debugged."
 )
 else:
-# If user is super user then we should check debugger library is 
loaded or not
-if user['is_superuser']:
-status_in, rid_pre = conn.execute_scalar("SHOW 
shared_preload_libraries")
-if not status_in:
-return internal_server_error(gettext("Could not fetch 
debugger plugin information."))
-
-# Need to check if plugin is really loaded or not with 
"plugin_debugger" string
-if "plugin_debugger" not in rid_pre:
-ret_status = False
-msg = gettext("The debugger plugin is not enabled. Please 
add the plugin to the shared_preload_libraries setting in the postgresql.conf 
file and restart the database server.")
-
 status_in, rid_tar = conn.execute_scalar(
 "SELECT count(*) FROM pg_proc WHERE proname = 
'pldbg_get_target_info'")
 if not status_in:


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

2017-06-22 Thread Murtuza Zabuawala
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
> ​'​
> ?
>
> ​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+.

>
> 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.​
>
> ​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.
>
> 5. The text like 'Rows Affected' or 'Duration' should be wrapped in
> 'gettext' for translation?
>
>
> On Thu, Jun 22, 2017 at 11:39 PM, Joao Pedro De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hi Hackers
>>
>> You can find attached a new version of this patch that corrects the issue
>> Dave mentioned. We've added direct unit tests for the CodeMirror react
>> wrapper to help prevent this bug from creeping in again. See
>> ./web/regression/javascript/code_mirror_spec.jsx
>>
>> Thanks,
>> Matt and João
>>
>> On Wed, Jun 21, 2017 at 12:22 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> Looking good. The only issue I found so far occurs if you open the
>>> query tool, then immediately click on the history tab:
>>>
>>> TypeError: Cannot read property 'CodeMirror' of undefined
>>> at Object. (sqleditor.js:882)
>>> at triggerEvents (backbone.js:208)
>>> at Object.trigger (backbone.js:148)
>>> at i.eventFunc (panel.js:101)
>>> at i.__trigger (wcDocker.js:1941)
>>> at i.__update (wcDocker.js:1818)
>>> at i.__onTabChange (wcDocker.js:3970)
>>> at i.__update (wcDocker.js:3482)
>>> at i.__update (wcDocker.js:2787)
>>> at wcDocker.js:20117
>>>
>>> On Wed, Jun 21, 2017 at 4:45 PM, George Gelashvili
>>>  wrote:
>>> > Hi
>>> >
>>> > We rebased this on top of latest master.
>>> >
>>> > Cheers,
>>> > Matt and George
>>> >
>>> > On Thu, Jun 15, 2017 at 10:43 AM, Dave Page  wrote:
>>> >>
>>> >> Hi
>>> >>
>>> >> We use Qt 5.8 at the moment, with the updated QtWebKit TP5 release
>>> >> from https://github.com/annulen/webkit/releases. The issue occurs on
>>> >> Windows and Mac, and probably Linux as well.
>>> >>
>>> >> Test builds can be found here: https://developer.pgadmin.org/
>>> ~dpage/debug/
>>> >>
>>> >> On Thu, Jun 15, 2017 at 2:33 PM, Sarah McAlear 
>>> >> wrote:
>>> >> > Hi Dave!
>>> >> >
>>> >> > Just to verify, which version of QT are you using? The Readme calls
>>> for
>>> >> > 5.5
>>> >> > at the newest. Could you send us the compiled version of the app?
>>> Are
>>> >> > you
>>> >> > only seeing this on Windows?
>>> >> >
>>> >> > Thanks,
>>> >> > Sarah & Shruti & João
>>> >> >
>>> >> > On Wed, Jun 14, 2017 at 3:46 PM, Sarah McAlear >> >
>>> >> > wrote:
>>> >> >>
>>> >> >> Sounds good! We're looking into it.
>>> >> >>
>>> >> >> On Wed, Jun 14, 2017 at 12:15 PM, Robert Eckhardt
>>> >> >> 
>>> >> >> wrote:
>>> >> >>>
>>> >> >>> Absolutely makes sense.
>>> >> >>>
>>> >> >>> Matt, Sarah,
>>> >> >>>
>>> >> >>> Do we understand the issues Dave is mentioning well enough to look
>>> >> >>> into
>>> >> >>> it and tackle it?
>>> >> >>>
>>> >> >>> -- Rob
>>> >> >>>
>>> >> >>> On Wed, Jun 14, 2017 at 8:12 AM, Dave Page 
>>> wrote:
>>> >> 
>>> >>  Hi,
>>> >> 
>>> >>  Before I commit anything else for this patch, we need to fix the
>>> >>  existing changes so they work in the desktop runtime (see the
>>> >>  previous
>>> >>  thread with the patches for the history pane changes). Have any
>>> of
>>> >>  your team been able to look at that yet?
>>> >> 
>>> >>  On Wed, Jun 14, 2017 at 4:07 PM, Sarah McAlear <
>>> smcal...@pivotal.io>
>>> >>  wrote:
>>> >>  > Hi Hackers!
>>> >>  >
>>> >>  > This patch includes a new pane in the history tab that
>>> displays the
>>> >>  > full
>>> >>  > formatted query and meta data about the query.
>>> >>  >
>>> >>  > Thanks!
>>> >>  > Shruti & Sarah
>>> >>  >
>>> >>  >
>>> >>  >
>>> >>  >
>>> >>  >
>>> >>  >
>>> >>  > --
>>> >>  > Sent via pgadmin-hackers mailing list
>>> >>  > (pgadmin-hack...@postgresql.org)
>>> >>  > To make changes to your subscription:
>>> >>  > http://www.postgresql.org/mailpref/pgadmin-hackers
>>> >>  >
>>> >> 
>>> >> 
>>> >> 
>>> >>  --
>>> >>  Dave Page
>>> >>  Blog: http://pgsnake.blogspot.com
>>> >>  Twitter: @pgsnake
>>> >> 
>>> >>  EnterpriseDB UK: http://www.en

Re: [pgAdmin4][Patch] To fix the issue in Debugger module

2017-06-23 Thread Murtuza Zabuawala
Yes Dave,

You are right, I tested and found that indirect debugging is not working.
But otherwise for direct debugging it works properly.


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jun 23, 2017 at 1:20 PM, Dave Page  wrote:

> On Fri, Jun 23, 2017 at 7:16 AM, Murtuza Zabuawala
>  wrote:
> > Hi,
> >
> > PFA patch to fix the issue in Debugger module where it was unable to
> start
> > debugging if 'plugin_debugger' can not found in shared_preload_libraries.
> > RM#2162
> >
> > Original patch by: Kit Yam Tse
> > (who reported the issue)
> >
> > I just re-based it against current code.
>
> Isn't that code required? We do need plugin_debugger to be present for
> global (indirect) debugging to work. I suppose it may not be required
> for direct debugging, but I haven't tested that.
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch] To fix the issue in Debugger module

2017-06-23 Thread Murtuza Zabuawala
Yes, I'm looking into it, I will send updated patch.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jun 23, 2017 at 2:32 PM, Dave Page  wrote:

> On Fri, Jun 23, 2017 at 9:56 AM, Murtuza Zabuawala
>  wrote:
> > Yes Dave,
> >
> > You are right, I tested and found that indirect debugging is not working.
> > But otherwise for direct debugging it works properly.
>
> Does the patch take that into account, or are you modifying it?
>
> > On Fri, Jun 23, 2017 at 1:20 PM, Dave Page  wrote:
> >>
> >> On Fri, Jun 23, 2017 at 7:16 AM, Murtuza Zabuawala
> >>  wrote:
> >> > Hi,
> >> >
> >> > PFA patch to fix the issue in Debugger module where it was unable to
> >> > start
> >> > debugging if 'plugin_debugger' can not found in
> >> > shared_preload_libraries.
> >> > RM#2162
> >> >
> >> > Original patch by: Kit Yam Tse
> >> > (who reported the issue)
> >> >
> >> > I just re-based it against current code.
> >>
> >> Isn't that code required? We do need plugin_debugger to be present for
> >> global (indirect) debugging to work. I suppose it may not be required
> >> for direct debugging, but I haven't tested that.
> >>
> >>
> >> --
> >> 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] To fix the issue in Debugger module

2017-06-23 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jun 23, 2017 at 2:38 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Yes, I'm looking into it, I will send updated patch.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Jun 23, 2017 at 2:32 PM, Dave Page  wrote:
>
>> On Fri, Jun 23, 2017 at 9:56 AM, Murtuza Zabuawala
>>  wrote:
>> > Yes Dave,
>> >
>> > You are right, I tested and found that indirect debugging is not
>> working.
>> > But otherwise for direct debugging it works properly.
>>
>> Does the patch take that into account, or are you modifying it?
>>
>> > On Fri, Jun 23, 2017 at 1:20 PM, Dave Page  wrote:
>> >>
>> >> On Fri, Jun 23, 2017 at 7:16 AM, Murtuza Zabuawala
>> >>  wrote:
>> >> > Hi,
>> >> >
>> >> > PFA patch to fix the issue in Debugger module where it was unable to
>> >> > start
>> >> > debugging if 'plugin_debugger' can not found in
>> >> > shared_preload_libraries.
>> >> > RM#2162
>> >> >
>> >> > Original patch by: Kit Yam Tse
>> >> > (who reported the issue)
>> >> >
>> >> > I just re-based it against current code.
>> >>
>> >> Isn't that code required? We do need plugin_debugger to be present for
>> >> global (indirect) debugging to work. I suppose it may not be required
>> >> for direct debugging, but I haven't tested that.
>> >>
>> >>
>> >> --
>> >> 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/tools/debugger/__init__.py 
b/web/pgadmin/tools/debugger/__init__.py
index 79e5eae..39bf23f 100644
--- a/web/pgadmin/tools/debugger/__init__.py
+++ b/web/pgadmin/tools/debugger/__init__.py
@@ -207,17 +207,6 @@ def init_function(node_type, sid, did, scid, fid, 
trid=None):
 " and cannot be debugged."
 )
 else:
-# If user is super user then we should check debugger library is 
loaded or not
-if user['is_superuser']:
-status_in, rid_pre = conn.execute_scalar("SHOW 
shared_preload_libraries")
-if not status_in:
-return internal_server_error(gettext("Could not fetch 
debugger plugin information."))
-
-# Need to check if plugin is really loaded or not with 
"plugin_debugger" string
-if "plugin_debugger" not in rid_pre:
-ret_status = False
-msg = gettext("The debugger plugin is not enabled. Please 
add the plugin to the shared_preload_libraries setting in the postgresql.conf 
file and restart the database server.")
-
 status_in, rid_tar = conn.execute_scalar(
 "SELECT count(*) FROM pg_proc WHERE proname = 
'pldbg_get_target_info'")
 if not status_in:
@@ -385,6 +374,31 @@ def initialize_target(debug_type, sid, did, scid, func_id, 
tri_id=None):
 if not status:
 return internal_server_error(errormsg=str(msg))
 
+user = manager.user_info
+if debug_type == 'indirect':
+# If user is super user then we should check debugger library is
+# loaded or not
+if user['is_superuser']:
+status_in, rid_pre = conn.execute_scalar(
+"SHOW shared_preload_libraries"
+)
+if not status_in:
+return internal_server_error(
+gettext("Could not fetch debugger plugin information.")
+)
+
+# Need to check if plugin is really loaded or not with
+# "plugin_debugger" string
+if "plugin_debugger" not in rid_pre:
+msg = gettext(
+"The debugger plugin is not enabled. " \
+"Please add the plugin to the shared_preload_libraries " \
+"setting

Re: [pgAdmin4][Patch] To fix the issue in Debugger module

2017-06-27 Thread Murtuza Zabuawala
Hi Dave

Please find updated patch,

On Fri, Jun 23, 2017 at 7:09 PM, Dave Page  wrote:

> Hi
>
> I'm unable to properly test this, as the debugger doesn't even seem to
> launch for a non-superuser. I just get a white tab, and a whole lot of
> polling indefinitely. Can you debug if you're not a superuser, but you
> own the function?
>
> I tested this scenario both ways,
1) Direct debugging: I was able to debug function, when debugger library is
loaded via shared preload libraries and also when it is not loaded.
2) Indirect debugging: I was not able to debug.
So, I have added the validation in both Server and Client side, Now we will
not show the option for the same if user is non-super user.

Looking at the patch itself, I wonder if the logic is still a little
> off. You need to be a superuser to use indirect debugging (because of
> the DOS potential), so shouldn't the superuser check be changed to "if
> !superuser then throw error"? As it is, if you're not superuser then
> it just skips the check for the plugin, which seems like it'll never
> end well.
>
> Fixed.

>
> On Fri, Jun 23, 2017 at 1:35 PM, Murtuza Zabuawala
>  wrote:
> > Hi Dave,
> >
> > Please find updated patch.
> >
> > --
> > Regards,
> > Murtuza Zabuawala
> > EnterpriseDB: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Fri, Jun 23, 2017 at 2:38 PM, Murtuza Zabuawala
> >  wrote:
> >>
> >> Yes, I'm looking into it, I will send updated patch.
> >>
> >> --
> >> Regards,
> >> Murtuza Zabuawala
> >> EnterpriseDB: http://www.enterprisedb.com
> >> The Enterprise PostgreSQL Company
> >>
> >> On Fri, Jun 23, 2017 at 2:32 PM, Dave Page  wrote:
> >>>
> >>> On Fri, Jun 23, 2017 at 9:56 AM, Murtuza Zabuawala
> >>>  wrote:
> >>> > Yes Dave,
> >>> >
> >>> > You are right, I tested and found that indirect debugging is not
> >>> > working.
> >>> > But otherwise for direct debugging it works properly.
> >>>
> >>> Does the patch take that into account, or are you modifying it?
> >>>
> >>> > On Fri, Jun 23, 2017 at 1:20 PM, Dave Page 
> wrote:
> >>> >>
> >>> >> On Fri, Jun 23, 2017 at 7:16 AM, Murtuza Zabuawala
> >>> >>  wrote:
> >>> >> > Hi,
> >>> >> >
> >>> >> > PFA patch to fix the issue in Debugger module where it was unable
> to
> >>> >> > start
> >>> >> > debugging if 'plugin_debugger' can not found in
> >>> >> > shared_preload_libraries.
> >>> >> > RM#2162
> >>> >> >
> >>> >> > Original patch by: Kit Yam Tse
> >>> >> > (who reported the issue)
> >>> >> >
> >>> >> > I just re-based it against current code.
> >>> >>
> >>> >> Isn't that code required? We do need plugin_debugger to be present
> for
> >>> >> global (indirect) debugging to work. I suppose it may not be
> required
> >>> >> for direct debugging, but I haven't tested that.
> >>> >>
> >>> >>
> >>> >> --
> >>> >> 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
>


RM_2162_v2.patch
Description: Binary data


[pgAdmin4][Patch] To add preferences for brace matching and auto brace closing

2017-06-27 Thread Murtuza Zabuawala
Hi,

Please find patch to add preferences for brace matching and auto brace
closing in SQL editor.
RM#2513

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index c6c5545..77e052f 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -549,6 +549,12 @@ def browser_js():
 editor_wrap_code_pref = prefs.preference('wrap_code')
 editor_wrap_code = editor_wrap_code_pref.get()
 
+brace_matching_pref = prefs.preference('brace_matching')
+brace_matching = brace_matching_pref.get()
+
+insert_pair_brackets_perf = prefs.preference('insert_pair_brackets')
+insert_pair_brackets = insert_pair_brackets_perf.get()
+
 for submodule in current_blueprint.submodules:
 snippets.extend(submodule.jssnippets)
 return make_response(
@@ -561,6 +567,8 @@ def browser_js():
 editor_tab_size=editor_tab_size,
 editor_use_spaces=editor_use_spaces,
 editor_wrap_code=editor_wrap_code,
+editor_brace_matching=brace_matching,
+editor_insert_pair_brackets=insert_pair_brackets,
 _=gettext
 ),
 200, {'Content-Type': 'application/x-javascript'})
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js 
b/web/pgadmin/browser/templates/browser/js/browser.js
index 4494e7a..e587348 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -7,7 +7,8 @@ define(
 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
 'pgadmin.browser.menu', 'pgadmin.browser.panel',
 'pgadmin.browser.error', 'pgadmin.browser.frame',
-'pgadmin.browser.node', 'pgadmin.browser.collection'
+'pgadmin.browser.node', 'pgadmin.browser.collection',
+'codemirror/addon/edit/matchbrackets', 
'codemirror/addon/edit/closebrackets'
   ], function(
 gettext, url_for, require, $, _, S, Bootstrap, pgAdmin, Alertify,
 CodeMirror, checkNodeVisibility
@@ -384,7 +385,9 @@ define(
 readOnly: true,
 extraKeys: pgAdmin.Browser.editor_shortcut_keys,
 tabSize: pgAdmin.Browser.editor_options.tabSize,
-lineWrapping: pgAdmin.Browser.editor_options.wrapCode
+lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
+autoCloseBrackets: 
pgAdmin.Browser.editor_options.insert_pair_brackets,
+matchBrackets: pgAdmin.Browser.editor_options.brace_matching
   });
 
   setTimeout(function() {
@@ -1830,7 +1833,9 @@ define(
 },
 editor_options: {
   tabSize: '{{ editor_tab_size }}',
-  wrapCode: '{{ editor_wrap_code }}' == 'True'
+  wrapCode: '{{ editor_wrap_code }}' == 'True',
+  insert_pair_brackets: '{{ editor_insert_pair_brackets }}' == 'True',
+  brace_matching: '{{ editor_brace_matching }}' == 'True'
 }
 
   });
diff --git a/web/pgadmin/static/css/codemirror.overrides.css 
b/web/pgadmin/static/css/codemirror.overrides.css
new file mode 100644
index 000..b486ee4
--- /dev/null
+++ b/web/pgadmin/static/css/codemirror.overrides.css
@@ -0,0 +1,5 @@
+/* To override inbuilt Green color for matchingbracket */
+.cm-s-default .CodeMirror-matchingbracket {
+color: #33 !important;
+background-color: #e8e8e8 !important;
+}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backform.pgadmin.js 
b/web/pgadmin/static/js/backform.pgadmin.js
index a82205e..27d5b4c 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -5,7 +5,8 @@
 define([
   'sources/gettext', 'underscore', 'underscore.string', 'jquery',
   'backbone', 'backform', 'backgrid', 'codemirror', 'pgadmin.backgrid',
-  'codemirror/mode/sql/sql', 'select2'
+  'codemirror/mode/sql/sql', 'select2', 
'codemirror/addon/edit/matchbrackets',
+  'codemirror/addon/edit/closebrackets'
   ],
  function(gettext, _, S, $, Backbone, Backform, Backgrid, CodeMirror) {
   // Export global even in AMD case in case this script is loaded with
@@ -1405,7 +1406,9 @@
 readOnly: true,
 extraKeys: pgAdmin.Browser.editor_shortcut_keys,
 tabSize: pgAdmin.Browser.editor_options.tabSize,
-lineWrapping: pgAdmin.Browser.editor_options.wrapCode
+lineWrapping: pgAdmin.Browser.editor_options.wrapCode,
+autoCloseBrackets: pgAdmin.Browser.editor_options.insert_pair_brackets,
+matchBrackets:

Re: [pgAdmin4][Patch] To add preferences for brace matching and auto brace closing

2017-06-27 Thread Murtuza Zabuawala
Sure Dave, I'll do the needful.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Tue, Jun 27, 2017 at 7:29 PM, Dave Page  wrote:

> Thanks - patch applied with some minor tweaks to enable both options by
> default and adjust the help wording.
>
> However, I realised right as I committed it, that you haven't updated the
> docs. Can you please update the screenshots affected and add the two new
> options to the docs please?
>
> Thanks.
>
> On Tue, Jun 27, 2017 at 9:21 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find patch to add preferences for brace matching and auto brace
>> closing in SQL editor.
>> RM#2513
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: 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: [RM2522] Improve grid/column select all operation

2017-06-30 Thread Murtuza Zabuawala
I guess so, number of columns do have overhead on selection & copy/paste
operation because of arbitrary copy paste feature, now we have to scan
start cell (first selected cell) & end cell (last selected cell) for each
row, In old code we were selecting complete row which was fast but now user
can select different columns as well, so we have scan for each selected
columns.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jun 30, 2017 at 12:07 PM, Dave Page  wrote:

> Hi
>
> On Thursday, June 29, 2017, Harshal Dhumal  com> wrote:
>
>>
>>
>> On Thu, Jun 29, 2017 at 4:33 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find attached patch for RM2522.
>>>
>>> With this patch grid/column select all time is reduce to ~1 second from
>>> 8-10 seconds.
>>>
>> This benchmarking is performed with 100k rows and 2 columns (int, text).
>>
>
> I see very little improvement (~15s to 14s). My test case has  108786 rows
> in it, and is generated from the query:
>
> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
> union all
> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
> union all
> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
> union all
> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
>
> Maybe the number of columns has something to do with it?
>
> AND... I'm still left with nothing being copied to the clipboard (the main
> issue by the way, which no patch for this so far seems to have tackled).
>
> Thanks.
>
>
>>
>>
>>>
>>> The solution was to use simple array concatenation instead of underscore
>>> union while getting index of all selected complete rows.
>>> Underscore union function is only useful when user selects different
>>> ranges from grid and those ranges overlaps. In this case union function
>>> removes duplicate (overlapped) rows.
>>> However result grid in sqleditor do not support overlapped row selection
>>> so we can simply cancat rows from different ranges without worrying about
>>> overlapped row selection.
>>>
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Sr. Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>


Re: [RM2522] Improve grid/column select all operation

2017-06-30 Thread Murtuza Zabuawala
++ Corrected sentence

On Fri, Jun 30, 2017 at 1:27 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> I guess so, number of columns do have overhead on selection & copy/paste
> operation because of arbitrary copy paste feature, now we have to scan
> start cell (first selected cell) & end cell (last selected cell) for each
> row, In old code we were selecting complete row which was fast but now user
> can select different columns as well, so we have to iterate over each
> selected columns.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Jun 30, 2017 at 12:07 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Thursday, June 29, 2017, Harshal Dhumal > om> wrote:
>>
>>>
>>>
>>> On Thu, Jun 29, 2017 at 4:33 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find attached patch for RM2522.
>>>>
>>>> With this patch grid/column select all time is reduce to ~1 second from
>>>> 8-10 seconds.
>>>>
>>> This benchmarking is performed with 100k rows and 2 columns (int, text).
>>>
>>
>> I see very little improvement (~15s to 14s). My test case has  108786
>> rows in it, and is generated from the query:
>>
>> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
>> union all
>> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
>> union all
>> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
>> union all
>> select * from pg_class c, pg_attribute a where c.oid = a.attrelid
>>
>> Maybe the number of columns has something to do with it?
>>
>> AND... I'm still left with nothing being copied to the clipboard (the
>> main issue by the way, which no patch for this so far seems to have
>> tackled).
>>
>> Thanks.
>>
>>
>>>
>>>
>>>>
>>>> The solution was to use simple array concatenation instead of
>>>> underscore union while getting index of all selected complete rows.
>>>> Underscore union function is only useful when user selects different
>>>> ranges from grid and those ranges overlaps. In this case union function
>>>> removes duplicate (overlapped) rows.
>>>> However result grid in sqleditor do not support overlapped row
>>>> selection so we can simply cancat rows from different ranges without
>>>> worrying about overlapped row selection.
>>>>
>>>>
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Sr. Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>


[pgAdmin4][Patch] To fix the issues in Debugger module

2017-06-30 Thread Murtuza Zabuawala
Hi,

Please find patch to fix the below issues,

1) Debugger page layout
RM#2512

2) To fix the issue when you user clicks on Stop button and gets connection
lost error.
RM#2511

@Dave,
When we stop the debugger using pldbg_abort_target() function and try to
start it again in the same connection, we are not able to do so because we
do not get response from plugin(async query results shows busy status
only), I think that is the reason why in pgAdmin3 we have disable all the
buttons and release the connection if user clicks on stop button, For time
being I have done the same in pgAdmin4 until we find the solution for this
issue.

Misc changes are for PEP-8.

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/debugger/__init__.py 
b/web/pgadmin/tools/debugger/__init__.py
index 8cebffc..35a0378 100644
--- a/web/pgadmin/tools/debugger/__init__.py
+++ b/web/pgadmin/tools/debugger/__init__.py
@@ -524,7 +524,7 @@ def initialize_target(debug_type, sid, did, scid, func_id, 
tri_id=None):
 'newBrowserTab': new_browser_tab})
 
 
-@blueprint.route('/close/', methods=["GET"])
+@blueprint.route('/close/', methods=["DELETE"])
 def close(trans_id):
 """
 close(trans_id)
@@ -849,10 +849,16 @@ def execute_debugger_query(trans_id, query_type):
 template_path = 'debugger/sql/v2'
 
 if conn.connected():
-sql = render_template("/".join([template_path, query_type + ".sql"]), 
session_id=obj['session_id'])
-# As the query type is continue or step_into or step_over then we may 
get result after some time so poll the
-# result. We need to update the frame id variable when user move the 
next step for debugging.
-if query_type == 'continue' or query_type == 'step_into' or query_type 
== 'step_over':
+sql = render_template(
+"/".join([template_path, query_type + ".sql"]),
+session_id=obj['session_id']
+)
+# As the query type is continue or step_into or step_over then we
+# may get result after some time so poll the result.
+# We need to update the frame id variable when user move the next
+# step for debugging.
+if query_type == 'continue' or query_type == 'step_into' or \
+query_type == 'step_over':
 # We should set the frame_id to 0 when execution starts.
 if obj['frame_id'] != 0:
 session_obj = debugger_data[str(trans_id)]
@@ -860,29 +866,30 @@ def execute_debugger_query(trans_id, query_type):
 update_session_debugger_transaction(trans_id, session_obj)
 
 status, result = conn.execute_async(sql)
-return make_json_response(data={'status': status, 'result': 
result})
+return make_json_response(
+data={'status': status, 'result': result}
+)
 elif query_type == 'abort_target':
 status, result = conn.execute_dict(sql)
-
-manager.release(did=obj['database_id'], conn_id=obj['conn_id'])
-
-# Delete the existing debugger data in session variable
-del session['debuggerData'][str(trans_id)]
-del session['functionData'][str(trans_id)]
-
 if not status:
 return internal_server_error(errormsg=result)
 else:
-return make_json_response(info=gettext('Target Aborted.'), 
data={'status': status, 'result': result})
+return make_json_response(
+info=gettext('Debugging aborted successfully.'),
+data={'status': 'Success', 'result': result}
+)
 else:
 status, result = conn.execute_dict(sql)
 if not status:
 return internal_server_error(errormsg=result)
 else:
-status = False
-result = gettext('Not connected to server or connection with the 
server has been closed.')
+result = gettext('Not connected to server or connection '
+ 'with the server has been closed.')
+return internal_server_error(errormsg=result)
 
-return make_json_response(data={'status': 'Success', 'result': 
result['rows']})
+return make_json_response(
+data={'status': 'Success', 'result': result['rows']}
+)
 
 
 @blueprint.route('/messages//', methods=["GET"])
@@ -915,9 +922,12 @@ def me

[pgAdmin4][Patch] To fix the duplicate entry in History panel

2017-06-30 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where duplicate entry is made of
successful executed query one with status message and one without status
message.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js 
b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 173301b..ad43c70 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -1854,7 +1854,6 @@ define([
 
   // Show message in message and history tab in case of query tool
   self.total_time = self.get_query_run_time(self.query_start_time, 
self.query_end_time);
-  self.update_msg_history(true, "", false);
   var msg1 = S(gettext("Successfully run. Total query runtime: 
%s.")).sprintf(self.total_time).value();
   var msg2 = S(gettext("%s rows 
affected.")).sprintf(self.rows_affected).value();
 


Re: [pgAdmin4][Patch]: Refactor of the History Tab

2017-06-30 Thread Murtuza Zabuawala
Hi,

On Fri, Jun 30, 2017 at 10:30 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> ​Hi,
>
> Review comments:
>
> 1) I see the font used for class .query-history .entry​ is monospace,
> shouldn't it be Helvetica as per style guide ? the font for Messages > text
> is also monospace.
>
> 2) Can 1px top border be added above first entry in left panel to
> differentiate from above panels ?
>
> 3) No query execution message appears if i run same query second time,
> please refer screenshot.
>
I think this isn't related to this patch, just now I have sent patch for
similar issue.

>
> Apart from this patch looks good.
>
> Thanks,
> Surinder
>
>
>
> On Fri, Jun 30, 2017 at 9:58 PM, Robert Eckhardt 
> wrote:
>
>> Surinder,
>>
>> It would be great if you could take a look at this an see if the style
>> changes are more inline with what you were thinking when you commented on
>> the first patch.
>>
>> -- Rob
>>
>> On Fri, Jun 30, 2017 at 11:55 AM, Shruti Iyer  wrote:
>>
>>> Hi Hackers,
>>>
>>> Attached is the patch that refactors the react components that supports
>>> the history detail pane. We moved inline styling. whenever possible, to
>>> scss.
>>>
>>> Thanks,
>>> Joao and Shruti
>>>
>>
>>
>


[pgAdmin4][Patch] To fix the issue in Debugger & Procedure module for EPAS server

2017-07-03 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where 'Debug' option was not displaying on
Package -> Function if the user if non-super user.
RM#1948

Another minor issue where there was a whitespace on SQL panel while
displaying reversed engineering sql for Procedure.
RM#2146

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
index c16d48a..4d34f13 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
@@ -291,7 +291,8 @@ class EdbFuncView(PGChildNodeView, DataTypeReader):
 row['oid'],
 pkgid,
 row['name'],
-icon="icon-" + self.node_type
+icon="icon-" + self.node_type,
+funcowner=row['funcowner']
 ),
 status=200
 )
@@ -302,7 +303,8 @@ class EdbFuncView(PGChildNodeView, DataTypeReader):
 row['oid'],
 pkgid,
 row['name'],
-icon="icon-" + self.node_type
+icon="icon-" + self.node_type,
+funcowner=row['funcowner']
 ))
 
 return make_json_response(
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.1_plus/node.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.1_plus/node.sql
index 55e3bf4..44e3456 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.1_plus/node.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.1_plus/node.sql
@@ -1,5 +1,6 @@
 SELECT  pg_proc.oid,
-pg_proc.proname || '(' || 
COALESCE(pg_catalog.pg_get_function_identity_arguments(pg_proc.oid), '') || ')' 
AS name
+pg_proc.proname || '(' || 
COALESCE(pg_catalog.pg_get_function_identity_arguments(pg_proc.oid), '') || ')' 
AS name,
+pg_get_userbyid(proowner) AS funcowner
 FROM pg_proc, pg_namespace
 WHERE format_type(prorettype, NULL) != 'void'
 {% if fnid %}
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.2_plus/node.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.2_plus/node.sql
index 77966e3..9a58068 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.2_plus/node.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/ppas/9.2_plus/node.sql
@@ -1,5 +1,6 @@
 SELECT  pg_proc.oid,
-pg_proc.proname || '(' || 
COALESCE(pg_catalog.pg_get_function_identity_arguments(pg_proc.oid), '') || ')' 
AS name
+pg_proc.proname || '(' || 
COALESCE(pg_catalog.pg_get_function_identity_arguments(pg_proc.oid), '') || ')' 
AS name,
+pg_get_userbyid(proowner) AS funcowner
 FROM pg_proc, pg_namespace
 WHERE format_type(prorettype, NULL) != 'void'
 {% if fnid %}
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/ppas/9.1_plus/node.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/ppas/9.1_plus/node.sql
index c2df4c9..4d2a0df 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/ppas/9.1_plus/node.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/ppas/9.1_plus/node.sql
@@ -1,5 +1,6 @@
 SELECT  pg_proc.oid,
-pg_proc.proname || '(' || 
COALESCE(pg_catalog.pg_get_function_identity_arguments(pg_proc.oid), '') || ')' 
AS name
+pg_proc.proname || '(' || 
COALESCE(pg_catalog.pg_get_function_identity_arguments(pg_proc.oid), '') || ')' 
AS name,
+pg_get_userbyid(proowner) AS funcowner
 FROM pg_proc, pg_namespace
 WHERE format_type(prorettype, NULL) = 'void'
 {% if fnid %}
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/ppas/9.2_plus/node.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/ed

[pgAdmin4][Patch]: Allow user to delete Tab via Shift-Tab in query editor

2017-07-05 Thread Murtuza Zabuawala
Hi,

PFA minor patch which will add functionality to allow user to delete Tab(s)
using Shift-Tab keys.
RM#1988

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js 
b/web/pgadmin/browser/templates/browser/js/browser.js
index 8a3a3b9..9ca3a16 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -1833,7 +1833,10 @@ define(
   "Ctrl-Alt-Left": "goGroupLeft",
   "Cmd-Alt-Left": "goGroupLeft",
   "Ctrl-Alt-Right": "goGroupRight",
-  "Cmd-Alt-Right": "goGroupRight"
+  "Cmd-Alt-Right": "goGroupRight",
+
+  // Allow user to delete Tab(s)
+  "Shift-Tab": "indentLess"
 },
 editor_options: {
   tabSize: '{{ editor_tab_size }}',


[pgAdmin4][Patch] To fix the issue in Function, Procedure & Trigger Function modules

2017-07-06 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue in Function, Procedure & Trigger Function
modules where user was not able to update object if user changes the code
definition.
RM#2537

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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 6f6ba19..9e69a1a 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 %}ROWS {{o_data.prorows}}{% 
endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
+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 %}
 
 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/update.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/update.sql
index 402c641..be24303 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 %}{% if data.prorows %}
 
-ROWS {{data.prorows}}{% elif o_data.prorows %}ROWS {{o_data.prorows}} 
{%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
+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 %}
 
 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.6_plus/create.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plus/create.sql
index 0e2495d..e3e9c18 100644
--- 
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
@@ -17,6 +17,7 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif 
%} FUNCTION {{ con
 
 LANGUAGE {{ data.lanname|qtLiteral }}
 {% if data.procost %}
+
 COST {{data.procost}}
 {% endif %}
 {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif 
data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if 
data.proleakproof %}LEAKPROOF {% endif %}
@@ -26,7 +27,9 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif 
%} FUNCTION {{ con
 {% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 
's') %}
 {% if data.proparallel == 'r' %}PARALLEL RESTRICTED{% elif data.proparallel == 
's' %}PARALLEL SAFE{% endif %}{% endif -%}
 {% if data.prorows %}
+
 ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in 
data.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.6_plus/update.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plus/update.sql
index 1f8f2f9..5c520bc 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plus/update.sql
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.6_plus/update.sql
@@ -32,7 +32,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

[pgAdmin4][Patch] Fix the issue in save password checkbox in "Create - Server" dialog.

2017-07-06 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue, where user is not able to save the
password even if config.py has option "ALLOW_SAVE_PASSWORD = True".
RM#2540

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js 
b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index 3456058..5f05c1d 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -692,7 +692,7 @@ define('pgadmin.node.server', [
 return m.get('connect_now') && m.isNew();
   },
   disabled: function(m) {
-return current_user.allow_save_password;
+return !current_user.allow_save_password;
   }
 },{
   id: 'role', label: gettext('Role'), type: 'text', group: 
gettext('Connection'),


Re: [pgAdmin4][Patch] To fix the issue in Function, Procedure & Trigger Function modules

2017-07-06 Thread Murtuza Zabuawala
Hi Dave,

This behaviour is from beginning I think and it is inherited from pgAdmin3.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Jul 6, 2017 at 5:58 PM, Dave Page  wrote:

> Hi
>
> On Thu, Jul 6, 2017 at 12:04 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix the issue in Function, Procedure & Trigger Function
>> modules where user was not able to update object if user changes the code
>> definition.
>> RM#2537
>>
>
> This still doesn't seem quite right - the Rows field seems to be always
> greyed out, so I cannot set it to test at all.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch] To fix the issue in Function, Procedure & Trigger Function modules

2017-07-06 Thread Murtuza Zabuawala
Sorry, I think my last statement was misleading.

No, It's not broken, I meant the behaviour is taken from pgAdmin3, It is
disabled by default but once you change the value of "Returns a set?"
(under Options tab) to Yes while creating new function it gets enabled.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Jul 6, 2017 at 6:37 PM, Dave Page  wrote:

> Maybe, but it's pretty clearly broken, so whilst you're fixing the
> template for that value, it would make sense to fix the UI too :-)
>
> On Thu, Jul 6, 2017 at 1:42 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> This behaviour is from beginning I think and it is inherited from
>> pgAdmin3.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Thu, Jul 6, 2017 at 5:58 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thu, Jul 6, 2017 at 12:04 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch to fix the issue in Function, Procedure & Trigger Function
>>>> modules where user was not able to update object if user changes the code
>>>> definition.
>>>> RM#2537
>>>>
>>>
>>> This still doesn't seem quite right - the Rows field seems to be always
>>> greyed out, so I cannot set it to test at all.
>>>
>>> --
>>> 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] To fix the issue in privileges control

2017-07-11 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue in privileges control, where privileges
were not displaying in IE10/11 when user click on it to grant privileges
for given role.
RM#1166

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js 
b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index e89fdbf..5be6c04 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -627,7 +627,9 @@
* focused active element.
*/
   setTimeout(function() {
-if (self.$el[0] != document.activeElement && 
!isDescendant(self.$el[0], document.activeElement)){
+var is_active_element_div_type = document.activeElement.tagName == 
'DIV';
+if (is_active_element_div_type && self.$el[0] != 
document.activeElement &&
+!isDescendant(self.$el[0], document.activeElement)) {
   var m = self.model;
   m.trigger('backgrid:edited', m, self.column, new 
Backgrid.Command(ev));
 }},10);


Re: [pgAdmin4][Patch] To fix the issue in privileges control

2017-07-11 Thread Murtuza Zabuawala
Please disregard previous patch, I'll send updated patch as I found one
issue.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Tue, Jul 11, 2017 at 4:49 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA minor patch to fix the issue in privileges control, where privileges
> were not displaying in IE10/11 when user click on it to grant privileges
> for given role.
> RM#1166
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch] To fix the issue in privileges control

2017-07-11 Thread Murtuza Zabuawala
Hi,

Please find updated patch.


On Tue, Jul 11, 2017 at 4:52 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Please disregard previous patch, I'll send updated patch as I found one
> issue.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Tue, Jul 11, 2017 at 4:49 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA minor patch to fix the issue in privileges control, where privileges
>> were not displaying in IE10/11 when user click on it to grant privileges
>> for given role.
>> RM#1166
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js 
b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index e89fdbf..654884c 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -627,7 +627,16 @@
* focused active element.
*/
   setTimeout(function() {
-if (self.$el[0] != document.activeElement && 
!isDescendant(self.$el[0], document.activeElement)){
+/*
+ Do not close the control if user clicks outside dialog window,
+ only close the row if user clicks on add button or on another row, if 
user
+ clicks somewhere else then we will get tagName as 'BODY' or 'WINDOW'
+*/
+var is_active_element = document.activeElement.tagName == 'DIV' ||
+document.activeElement.tagName == 'BUTTON';
+
+if (is_active_element && self.$el[0] != document.activeElement &&
+!isDescendant(self.$el[0], document.activeElement)) {
   var m = self.model;
   m.trigger('backgrid:edited', m, self.column, new 
Backgrid.Command(ev));
 }},10);


[pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-12 Thread Murtuza Zabuawala
Hi,

PFA patch which will add functionality to allow user to comment/uncomment
code in query editor.
RM#2456

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/docs/en_US/keyboard_shortcuts.rst 
b/docs/en_US/keyboard_shortcuts.rst
index 2194d63..9de6103 100644
--- a/docs/en_US/keyboard_shortcuts.rst
+++ b/docs/en_US/keyboard_shortcuts.rst
@@ -59,6 +59,8 @@ When using the syntax-highlighting SQL editors, the following 
shortcuts are avai
 
+--+--+-+
 | Shift+Tab| Shift+Tab| Un-indent selected text
 |
 
+--+--+-+
+| Shift+Ctrl+/ | Shift+Ctrl+/ | Comment/Uncomment selected 
text |
++--+--+-+
 
 **Query Tool**
 
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html 
b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 4bb38c4..b9fe89d 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -217,6 +217,10 @@
 
 
 
+
+
+ {{ _('Comment/Uncomment Code') }} 
+
 
 
  {{ _('Clear Query Window') }} 
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js 
b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 8a797ab..3cf9fc6 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -28,6 +28,7 @@ define([
 'codemirror/addon/search/jump-to-line',
 'codemirror/addon/edit/matchbrackets',
 'codemirror/addon/edit/closebrackets',
+'codemirror/addon/comment/comment',
 
 'backgrid.sizeable.columns',
 'slick.pgadmin.formatters',
@@ -50,7 +51,8 @@ define([
 // Define key codes for shortcut keys
 var F5_KEY = 116,
 F7_KEY = 118,
-F8_KEY = 119;
+F8_KEY = 119,
+FWD_SLASH_KEY = 191;
 
 var is_query_running = false;
 
@@ -102,6 +104,7 @@ define([
 "click #btn-explain-costs": "on_explain_costs",
 "click #btn-explain-buffers": "on_explain_buffers",
 "click #btn-explain-timing": "on_explain_timing",
+"click #btn-toggle-comment": "on_toggle_comment_code",
 "change .limit": "on_limit_change",
 "keydown": "keyAction"
   },
@@ -1288,6 +1291,17 @@ define([
 );
   },
 
+  // Callback function for the comment/uncomment selected code
+  on_toggle_comment_code: function() {
+var self = this;
+// Trigger the comment signal to the SqlEditorController class
+self.handler.trigger(
+'pgadmin-sqleditor:toggle_comment_code',
+self,
+self.handler
+);
+  },
+
   // Callback function for the clear button click.
   on_clear: function(ev) {
 var self = this, sql;
@@ -1498,6 +1512,10 @@ define([
   // Download query result as CSV.
   this.on_download(ev);
   ev.preventDefault();
+} else if (ev.shiftKey && ev.ctrlKey  && keyCode == FWD_SLASH_KEY ) {
+  // Toggle comments
+  this.on_toggle_comment_code(ev);
+  ev.preventDefault();
 }
   }
 });
@@ -1587,6 +1605,8 @@ define([
   self.on('pgadmin-sqleditor:button:explain-costs', 
self._explain_costs, self);
   self.on('pgadmin-sqleditor:button:explain-buffers', 
self._explain_buffers, self);
   self.on('pgadmin-sqleditor:button:explain-timing', 
self._explain_timing, self);
+  self.on('pgadmin-sqleditor:toggle_comment_code', 
self._toggle_comment_code, self);
+
 
   if (self.is_query_tool) {
 self.gridView.query_tool_obj.refresh();
@@ -3635,6 +3655,25 @@ define([
 },
 
 /*
+ * This function will comment/uncomment code
+ */
+_toggle_comment_code: function() {
+  var self = this, editor = self.gridView.query_tool_obj,
+  selected_code = editor.getSelection(),
+  sql = selected_code.length > 0 ? selected_code : editor.getValue();
+  // If it is an empty query, do nothing.
+  if (sql.length <= 0) return;
+
+  // Find the code selection range
+  var range = {
+from: editor.getCursor(tr

Re: pgAdmin 4 commit: Fix IE11 alert layout again.

2017-07-13 Thread Murtuza Zabuawala
Hello Surinder,

Looks recent commits to alert css broke the fading out animation layout.

Steps to re-produce (tested on Chrome & FF):
1) Open query tool
2) Execute 'select 1;'
3) Alert will displays properly but now take a closer look when alert fades
out from screen, icon goes on top of alert message and layout becomes kind
of square shape.


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

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

> Fix IE11 alert layout again.
>
> Branch
> --
> master
>
> Details
> ---
> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=
> 33e56272ca2430a2a85184951568ad324796bf94
> Author: Surinder Kumar 
>
> Modified Files
> --
> web/pgadmin/static/scss/_alertify.overrides.scss | 4 
> 1 file changed, 4 insertions(+)
>
>


[pgAdmin4][Patch] Not to display PID comma separated in statistics panel

2017-07-13 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where PID column was displaying comma
separated in statistics panel.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/misc/statistics/static/js/statistics.js 
b/web/pgadmin/misc/statistics/static/js/statistics.js
index 1377c1e..ab8fbb8 100644
--- a/web/pgadmin/misc/statistics/static/js/statistics.js
+++ b/web/pgadmin/misc/statistics/static/js/statistics.js
@@ -324,14 +324,23 @@ define([
   this.columns = [];
   for (var idx in columns) {
 var rawColumn = columns[idx],
-col = {
+cell_type = typeCellMapper[rawColumn['type_code']] || 'string';
+
+// Don't show PID comma separated
+if(rawColumn['name'] == 'PID') {
+  cell_type = cell_type.extend({
+orderSeparator: ''
+  });
+}
+
+var col = {
 editable: false,
 name: rawColumn['name'],
-cell: typeCellMapper[rawColumn['type_code']] || 'string'
-   };
-   if (_.indexOf(prettifyFields, rawColumn['name']) != -1) {
-col['formatter'] = SizeFormatter
-   }
+cell: cell_type
+};
+if (_.indexOf(prettifyFields, rawColumn['name']) != -1) {
+  col['formatter'] = SizeFormatter
+}
 this.columns.push(col);
 
   }


[pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-13 Thread Murtuza Zabuawala
hiHi,

PFA patch to add functionality which will allow super user to cancel long
running queries from dashboard.
RM#1812

*Steps used to test:*
1) Open psql session, Connect to 'test' database on respective server
2) Execute "select pg_sleep(1000);"
3) Open pgAdmin4
4) Connect to respective server
5) Click on Dashboard
6) Check "Sessions" tab under "Server activity" section then look for
active sessions for test database.
7) Click on cancel button and cancel the active session
8) Check psql session now, you will see "ERROR:  canceling statement due to
user request"



--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/dashboard/__init__.py 
b/web/pgadmin/dashboard/__init__.py
index 8f813d7..897bfc0 100644
--- a/web/pgadmin/dashboard/__init__.py
+++ b/web/pgadmin/dashboard/__init__.py
@@ -409,3 +409,36 @@ def config(sid=None):
 :return:
 """
 return get_data(sid, None, 'config.sql')
+
+
+@blueprint.route(
+'/cancel_session//', methods=['DELETE']
+)
+@blueprint.route(
+'/cancel_session///', methods=['DELETE']
+)
+@login_required
+@check_precondition
+def cancel_session(sid=None, did=None, pid=None):
+"""
+This function cancel the specific session
+:param sid: server id
+:param did: database id
+:param pid: session/process id
+:return: Response
+"""
+user = g.manager.user_info
+if user and user.get('is_superuser'):
+sql = "SELECT pg_cancel_backend({0});".format(pid)
+status, res = g.conn.execute_scalar(sql)
+if not status:
+return internal_server_error(errormsg=res)
+
+return ajax_response(
+response=gettext("Success") if res else gettext("Failed"),
+status=200
+)
+else:
+return internal_server_error(
+errormsg=gettext("User must be a superuser to perform this task.")
+)
diff --git a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js 
b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
index 34a1ab7..35f5a2b 100644
--- a/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
+++ b/web/pgadmin/dashboard/templates/dashboard/js/dashboard.js
@@ -1,8 +1,9 @@
 define([
-'require', 'jquery', 'pgadmin', 'underscore', 'backbone', 
'sources/gettext', 'flotr2', 'wcdocker',
+'require', 'jquery', 'pgadmin', 'underscore', 'backbone', 
'sources/gettext',
+'alertify', 'sources/alerts/alertify_wrapper', 'flotr2', 'wcdocker',
 'pgadmin.browser', 'bootstrap'
 ],
-function(r, $, pgAdmin, _, Backbone, gettext) {
+function(r, $, pgAdmin, _, Backbone, gettext, alertify, AlertifyWrapper) {
 
   var wcDocker = window.wcDocker,
   pgBrowser = pgAdmin.Browser;
@@ -11,7 +12,65 @@ function(r, $, pgAdmin, _, Backbone, gettext) {
   if (pgAdmin.Dashboard)
 return;
 
-  var dashboardVisible = true;
+  var dashboardVisible = true,
+cancel_session_url = '',
+is_super_user = false;
+
+  // Custom BackGrid cell, Responsible for cancelling active sessions
+  var cancelSessionCell = Backgrid.Extension.DeleteCell.extend({
+render: function () {
+  this.$el.empty();
+  this.$el.html(
+""
+  );
+  this.delegateEvents();
+  return this;
+},
+deleteRow: function(e) {
+  var self = this;
+  e.preventDefault();
+  var _title = gettext('Cancel Active Session?'),
+_txtConfirm = gettext('Are you sure you wish to cancel this active 
session?');
+
+  if (self.model.get('state') == 'idle') {
+_title = gettext('Cancel Idle Session?');
+_txtConfirm = gettext('Are you sure you wish to cancel this idle 
session?');
+  }
+
+  alertify.confirm(
+_title,
+_txtConfirm,
+function(evt) {
+  $.ajax({
+url: cancel_session_url + self.model.get('pid'),
+type:'DELETE',
+success: function(res) {
+  var alertifyWrapper = new AlertifyWrapper();
+  if (res == gettext('Success')) {
+alertifyWrapper.success(gettext('Session cancelled 
successfully.'));
+  } else {
+alertifyWrapper.error(gettext('Error during canceling 
session.'));
+  }
+},
+error: function(xhr, status, error) {

Re: Testing out font changes in query editor tool

2017-07-13 Thread Murtuza Zabuawala
Hi Shirley,

It's easy on the eyes :)

~M

On Thu, Jul 13, 2017 at 10:00 PM, Shirley Wang  wrote:

> Hello!
>
> We're trying out a new font in the query editor tool. Attached is a patch
> that changes the font.
>
> We'd like to know how this change affects your experience working in the
> query tool.
>
> Thanks!
> George and Shirley
>


Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-17 Thread Murtuza Zabuawala
Hi Dave,

On Mon, Jul 17, 2017 at 2:33 PM, Dave Page  wrote:

> Hi
>
> On Wed, Jul 12, 2017 at 1:16 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch which will add functionality to allow user to comment/uncomment
>> code in query editor.
>> RM#2456
>>
>
> This is cool, but I'm not sure it's right as-is:
>
> * I prefer SQL style commenting, e.g.
>
> -- This is a comment
>
> Should we make that a config option if CodeMirror can do it? Or a
> different hotkey?
>
>
I'll check the extension code and update you accordingly, and It will be
good idea to keep the both the options because with large code block
current style works the best.

> * You've added it as an option to the Clear XXX dropdown, which really
> isn't the right place in my opinion. Should we add a new drop down for
> this, and include some/all of the other Editing options on there? E.g.
> tab/shift-tab.
>
> I thought that is misc options dropdown for our editor, but I don't see
any point adding new drop down for one single option, Can we add new button
instead?

> * I think the docs should say Ctrl+Shift+/ rather than Shift+Ctrl+/, and
> be ordered in the table to reflect that. It seems more natural to me.
>
> Initially I wrote ctrl + shift + /only but when I saw all other shortcuts
starts with Shift , then I changed it to shift + ctrl + / :)

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


Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-17 Thread Murtuza Zabuawala
On Mon, Jul 17, 2017 at 3:01 PM, Dave Page  wrote:

> Hi
>
> On Thu, Jul 13, 2017 at 2:53 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> hiHi,
>>
>> PFA patch to add functionality which will allow super user to cancel long
>> running queries from dashboard.
>> RM#1812
>>
>> *Steps used to test:*
>> 1) Open psql session, Connect to 'test' database on respective server
>> 2) Execute "select pg_sleep(1000);"
>> 3) Open pgAdmin4
>> 4) Connect to respective server
>> 5) Click on Dashboard
>> 6) Check "Sessions" tab under "Server activity" section then look for
>> active sessions for test database.
>> 7) Click on cancel button and cancel the active session
>> 8) Check psql session now, you will see "ERROR:  canceling statement due
>> to user request"
>>
>> Some comments:
>
> - The action here is to cancel the active query in the backend, not the
> session - so messages etc. should say things like "Cancel Active Query?"
>
> - The grid should refresh following the cancel operation.
>
> - Can you fix the vertical alignment while you're working on this? The new
> button really makes the poor alignment stand out.
>
> - This should not be superuser only - regular users should be able to
> cancel their own queries.
>
> - On PG10, background workers are also shown in the dashboard. Should we
> prevent attempts to cancel their work (they'll fail anyway I believe).
>
> Thanks!
>
>
Sure, I'll work on these comments & send updated patch.

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


[RM2544][pgAdmin4] Add SSL database connection support in Regression tests

2017-07-17 Thread Murtuza Zabuawala
Hi,

PFA patch to add SSL support for database connection.
RM#2170

Included test to check if current connection is using SSL or not.


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
index cf1dc9f..cae1df0 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
@@ -52,7 +52,8 @@ class CastsAddTestCase(BaseTestGenerator):
  self.server['username'],
  self.server['db_password'],
  self.server['host'],
- self.server['port'])
+ self.server['port'],
+ self.server['sslmode'])
 cast_utils.drop_cast(connection, self.data["srctyp"],
  self.data["trgtyp"])
 database_utils.disconnect_database(self, self.server_id,
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
index 210e49d..5925a20 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
@@ -48,7 +48,8 @@ class CastsDeleteTestCase(BaseTestGenerator):
  self.server['username'],
  self.server['db_password'],
  self.server['host'],
- self.server['port'])
+ self.server['port'],
+ self.server['sslmode'])
 response = cast_utils.verify_cast(connection, self.source_type,
   self.target_type)
 if len(response) == 0:
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
index 814508b..f734884 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
@@ -58,7 +58,8 @@ class CastsGetTestCase(BaseTestGenerator):
  self.server['username'],
  self.server['db_password'],
  self.server['host'],
- self.server['port'])
+ self.server['port'],
+ self.server['sslmode'])
 cast_utils.drop_cast(connection, self.source_type,
  self.target_type)
 database_utils.disconnect_database(self, self.server_id,
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/utils.py 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/utils.py
index b1875c0..ea49828 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/utils.py
@@ -43,7 +43,8 @@ def create_cast(server, source_type, target_type):
server['username'],
server['db_password'],
server['host'],
-   server['port'])
+   server['port'],
+   server['sslmode'])
 old_isolation_level = connection.isolation_level
 connection.set_isolation_level(0)
 pg_cursor = connection.cursor()
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/tests/utils.py
 
b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/tests/utils.py
index 1e4040d..ae6b1d7 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/tests/utils.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/tests/utils.py
@@ -37,7 +37,8 @@ def create_event_trigger(server, db_na

Re: [RM2544][pgAdmin4] Add SSL database connection support in Regression tests

2017-07-17 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch for the same.


On Mon, Jul 17, 2017 at 8:59 PM, Dave Page  wrote:

> Hi
>
> On Mon, Jul 17, 2017 at 2:59 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to add SSL support for database connection.
>> RM#2170
>>
>> Included test to check if current connection is using SSL or not
>>
>
> I think the SSL test needs a little work. Instead of:
>
>  Test for SSL connection check ... Traceback (most recent call last):
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/tests/test_check_ssl_connection.py", line 42, in runTest
> self.server['sslmode']
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/unittest/case.py", line 408, in skipTest
> raise SkipTest(reason)
> SkipTest: Cannot run SSL connection check test with 'prefer' sslmode
> skipped "Cannot run SSL connection check test with 'prefer' sslmode"
>
> I would expect to see:
>
> runTest (pgadmin.browser.server_groups.servers.tests.test_
> check_ssl_connection.TestSSLConnectionCheck)
> Test SSL Connection ... skipped "Cannot run SSL connection check test with
> 'prefer' sslmode"
> 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/casts/tests/test_cast_add.py
 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
index cf1dc9f..cae1df0 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_add.py
@@ -52,7 +52,8 @@ class CastsAddTestCase(BaseTestGenerator):
  self.server['username'],
  self.server['db_password'],
  self.server['host'],
- self.server['port'])
+ self.server['port'],
+ self.server['sslmode'])
 cast_utils.drop_cast(connection, self.data["srctyp"],
  self.data["trgtyp"])
 database_utils.disconnect_database(self, self.server_id,
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
index 210e49d..5925a20 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_delete.py
@@ -48,7 +48,8 @@ class CastsDeleteTestCase(BaseTestGenerator):
  self.server['username'],
  self.server['db_password'],
  self.server['host'],
- self.server['port'])
+ self.server['port'],
+ self.server['sslmode'])
 response = cast_utils.verify_cast(connection, self.source_type,
   self.target_type)
 if len(response) == 0:
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
index 814508b..f734884 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/casts/tests/test_cast_get.py
@@ -58,7 +58,8 @@ class CastsGetTestCase(BaseTestGenerator):
  self.server['username'],
  self.server['db_password'],
  self.server['host'],
- self.server['port'])
+ self.server['port'],
+ self.server['sslmode'])
 cast_utils.drop_cast(connection, self.source_type,
  self.target_type)
 database_utils.disconnect_database(self, self.server_id,
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/casts/tests/utils.py 
b/web/pgadmin/

Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-18 Thread Murtuza Zabuawala
Hi Shirley,

On Tue, Jul 18, 2017 at 1:21 AM, Shirley Wang  wrote:

> Hi!
>
> I can't seem to get the patch to completely work on my computer, only the
> close icon shows up plus the dialog and success/error messages, but here
> are some comments:
>
> Because  we are just cancelling the active running query, so if the start
of the session is 'Active' when you cancel it will simply goto 'Idle' stat.

> +1 to Dave's comment about refreshing after the cancel operation
>
> I'll fix this.

> - We're working on a patch for updating alerts in the Dashboard tab which
> updates the grays in the Database activities panel and changes the border
> around the refresh button and search bar to 1px. This hasn't been submitted
> yet but just a heads up as you work on the alignment.
>
> - Something to consider is how a super user will identify which session
> should be closed. Is that information there?
>
> I think super user can cancel everything except main connection session &
as Dave mentioned in previous email that background workers in PG10.

> - Are there sessions that should never be closed? If so, do they also need
> close buttons? (Probably not, because that will lead the user to an error
> message, which is not fun)
>
> In Backgrid, we can not exclude specific column from certain rows if it
renders in one row then it will render for every row in the grid, What we
can do is, it will throw an error when user is not eligible to cancel the
active running query.

> - Perhaps this is a good feature to review with Chethana! :)
>
> On Mon, Jul 17, 2017 at 5:37 AM Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> On Mon, Jul 17, 2017 at 3:01 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thu, Jul 13, 2017 at 2:53 PM, Murtuza Zabuawala >> enterprisedb.com> wrote:
>>>
>>>> hiHi,
>>>>
>>>> PFA patch to add functionality which will allow super user to cancel
>>>> long running queries from dashboard.
>>>> RM#1812
>>>>
>>>> *Steps used to test:*
>>>> 1) Open psql session, Connect to 'test' database on respective server
>>>> 2) Execute "select pg_sleep(1000);"
>>>> 3) Open pgAdmin4
>>>> 4) Connect to respective server
>>>> 5) Click on Dashboard
>>>> 6) Check "Sessions" tab under "Server activity" section then look for
>>>> active sessions for test database.
>>>> 7) Click on cancel button and cancel the active session
>>>> 8) Check psql session now, you will see "ERROR:  canceling statement
>>>> due to user request"
>>>>
>>>> Some comments:
>>>
>>> - The action here is to cancel the active query in the backend, not the
>>> session - so messages etc. should say things like "Cancel Active Query?"
>>>
>>>
>> - The grid should refresh following the cancel operation.
>>>
>>> - Can you fix the vertical alignment while you're working on this? The
>>> new button really makes the poor alignment stand out.
>>>
>>> - This should not be superuser only - regular users should be able to
>>> cancel their own queries.
>>>
>>> - On PG10, background workers are also shown in the dashboard. Should we
>>> prevent attempts to cancel their work (they'll fail anyway I believe).
>>>
>>> Thanks!
>>>
>>>
>> Sure, I'll work on these comments & send updated patch.
>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>


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

2017-07-18 Thread Murtuza Zabuawala
Great job Surinder, Load time ~2 sec on browser :)

[image: Inline image 1]


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Tue, Jul 18, 2017 at 9:01 PM, Dave Page  wrote:

> Thanks, applied.
>
> On Tue, Jul 18, 2017 at 4:12 PM, Surinder Kumar <
> surinder.ku...@enterprisedb.com> wrote:
>
>> Hi
>>
>> 1. As Slickgrid has dependency of `jQuery-ui`, it was missed. now added.
>> 2. Column sorting for collection nodes sometimes failing when clicked on
>> different collection nodes.
>>
>> Please find attached patch.
>>
>> Thanks
>> Surinder
>>
>> On Tue, Jul 18, 2017 at 8:20 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> 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.
>>>>
>>> ​Thanks to all​
>>
>>>
>>>> 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.
>>>>>>>>&g

Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-19 Thread Murtuza Zabuawala
Hi,

PFA updated patch,
1) Added Keyboard shortcuts to comment line, uncomment line and
comment/uncomment block of code also added drop-down for the same.
2) Also added options for indent & unindent code in the same drop-down.
3) Updated shortcut documents accordingly.

Please review.

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

> Hi
>
> On Mon, Jul 17, 2017 at 10:31 AM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Mon, Jul 17, 2017 at 2:33 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Wed, Jul 12, 2017 at 1:16 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch which will add functionality to allow user to
>>>> comment/uncomment code in query editor.
>>>> RM#2456
>>>>
>>>
>>> This is cool, but I'm not sure it's right as-is:
>>>
>>> * I prefer SQL style commenting, e.g.
>>>
>>> -- This is a comment
>>>
>>> Should we make that a config option if CodeMirror can do it? Or a
>>> different hotkey?
>>>
>>>
>> I'll check the extension code and update you accordingly, and It will be
>> good idea to keep the both the options because with large code block
>> current style works the best.
>>
>
> Right.
>
>
>> * You've added it as an option to the Clear XXX dropdown, which really
>>> isn't the right place in my opinion. Should we add a new drop down for
>>> this, and include some/all of the other Editing options on there? E.g.
>>> tab/shift-tab.
>>>
>>> I thought that is misc options dropdown for our editor, but I don't see
>> any point adding new drop down for one single option, Can we add new button
>> instead?
>>
>
> I think you missed this bit:  "and include some/all of the other Editing
> options on there? E.g. tab/shift-tab.". Essentially, we'd be adding an Edit
> menu...
>
>
>> * I think the docs should say Ctrl+Shift+/ rather than Shift+Ctrl+/, and
>>> be ordered in the table to reflect that. It seems more natural to me.
>>>
>>> Initially I wrote ctrl + shift + /only but when I saw all other
>> shortcuts starts with Shift , then I changed it to shift + ctrl + / :)
>>
>
> No they don't - Ctrl+Alt+Left for example. I believe it's normal to put
> Ctrl first, then Shift as it's a modifier.
>
>
>> Thoughts?
>>>
>>> --
>>> 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/docs/en_US/keyboard_shortcuts.rst 
b/docs/en_US/keyboard_shortcuts.rst
index 2194d63..194a2c5 100644
--- a/docs/en_US/keyboard_shortcuts.rst
+++ b/docs/en_US/keyboard_shortcuts.rst
@@ -59,6 +59,12 @@ When using the syntax-highlighting SQL editors, the 
following shortcuts are avai
 
+--+--+-+
 | Shift+Tab| Shift+Tab| Un-indent selected text
 |
 
+--+--+-+
+| Ctrl+Shift+, | Ctrl+Shift+, | Comment selected code (Inline) 
 |
++--+--+-+
+| Ctrl+Shift+. | Ctrl+Shift+. | Uncomment selected code 
(Inline)|
++--+--+-+
+| Ctrl+Shift+/ | Ctrl+Shift+/ | Comment/Uncomment code (Block) 
 |
++--+--+-+
 
 **Query Tool**
 
diff --git a/web/pgadmin/static/bundle/codemirror.js 
b/web/pgadmin/static/bundle/codemirror.js
index 6c3525b..c8766ff 100644
--- a/web/pgadmin/static/bundle/codemirror.js
+++ b/web/pgadmin/static/bundle/codemirror.js
@@ -13,6 +13,7 @@ import 'codemirror/addon/search/searchcursor';
 import 'codemirror/addon/search/jump-to-line';
 import 'codemirror/addon/edit/matchbrackets';
 import 'codemirror/addon/edit/closebrackets';
+import 'codemirror/addon/comment/comment'
 import 'pgadmin.sqlfoldc

Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-19 Thread Murtuza Zabuawala
Just a FYI,
You need to run yarn bundle for this to be working as Surinder has moved
all the CodeMirror code into bundle package.

On Wed, Jul 19, 2017 at 2:20 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA updated patch,
> 1) Added Keyboard shortcuts to comment line, uncomment line and
> comment/uncomment block of code also added drop-down for the same.
> 2) Also added options for indent & unindent code in the same drop-down.
> 3) Updated shortcut documents accordingly.
>
> Please review.
>
> On Mon, Jul 17, 2017 at 3:05 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Mon, Jul 17, 2017 at 10:31 AM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> On Mon, Jul 17, 2017 at 2:33 PM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> On Wed, Jul 12, 2017 at 1:16 PM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> PFA patch which will add functionality to allow user to
>>>>> comment/uncomment code in query editor.
>>>>> RM#2456
>>>>>
>>>>
>>>> This is cool, but I'm not sure it's right as-is:
>>>>
>>>> * I prefer SQL style commenting, e.g.
>>>>
>>>> -- This is a comment
>>>>
>>>> Should we make that a config option if CodeMirror can do it? Or a
>>>> different hotkey?
>>>>
>>>>
>>> I'll check the extension code and update you accordingly, and It will be
>>> good idea to keep the both the options because with large code block
>>> current style works the best.
>>>
>>
>> Right.
>>
>>
>>> * You've added it as an option to the Clear XXX dropdown, which really
>>>> isn't the right place in my opinion. Should we add a new drop down for
>>>> this, and include some/all of the other Editing options on there? E.g.
>>>> tab/shift-tab.
>>>>
>>>> I thought that is misc options dropdown for our editor, but I don't see
>>> any point adding new drop down for one single option, Can we add new button
>>> instead?
>>>
>>
>> I think you missed this bit:  "and include some/all of the other Editing
>> options on there? E.g. tab/shift-tab.". Essentially, we'd be adding an Edit
>> menu...
>>
>>
>>> * I think the docs should say Ctrl+Shift+/ rather than Shift+Ctrl+/, and
>>>> be ordered in the table to reflect that. It seems more natural to me.
>>>>
>>>> Initially I wrote ctrl + shift + /only but when I saw all other
>>> shortcuts starts with Shift , then I changed it to shift + ctrl + / :)
>>>
>>
>> No they don't - Ctrl+Alt+Left for example. I believe it's normal to put
>> Ctrl first, then Shift as it's a modifier.
>>
>>
>>> Thoughts?
>>>>
>>>> --
>>>> 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]: Allow user to Comment/Uncomment code in query editor

2017-07-19 Thread Murtuza Zabuawala
Thank you Dave.

On Wed, Jul 19, 2017 at 4:17 PM, Dave Page  wrote:

> Thanks, applied.
>
> I also took the opportunity to tidy up the menus a little and add access
> keys for accessibility.
>
> One change I made was to make the Edit and Clear menus not have a default
> option - e.g. instead of a button with a drop-down next to it, they're now
> a single dropdown button with icon. I think this works better as there are
> no obvious candidates for the "default" option for those menus. I'm not
> overly enthusiastic about the look of those buttons though, so if anyone
> has a better idea how they should be styled, please yelp (CCing Chethana
> for his input as well)...
>
>
>
> On Wed, Jul 19, 2017 at 9:56 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Just a FYI,
>> You need to run yarn bundle for this to be working as Surinder has moved
>> all the CodeMirror code into bundle package.
>>
>> On Wed, Jul 19, 2017 at 2:20 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA updated patch,
>>> 1) Added Keyboard shortcuts to comment line, uncomment line and
>>> comment/uncomment block of code also added drop-down for the same.
>>> 2) Also added options for indent & unindent code in the same drop-down.
>>> 3) Updated shortcut documents accordingly.
>>>
>>> Please review.
>>>
>>> On Mon, Jul 17, 2017 at 3:05 PM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> On Mon, Jul 17, 2017 at 10:31 AM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Dave,
>>>>>
>>>>> On Mon, Jul 17, 2017 at 2:33 PM, Dave Page  wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> On Wed, Jul 12, 2017 at 1:16 PM, Murtuza Zabuawala <
>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> PFA patch which will add functionality to allow user to
>>>>>>> comment/uncomment code in query editor.
>>>>>>> RM#2456
>>>>>>>
>>>>>>
>>>>>> This is cool, but I'm not sure it's right as-is:
>>>>>>
>>>>>> * I prefer SQL style commenting, e.g.
>>>>>>
>>>>>> -- This is a comment
>>>>>>
>>>>>> Should we make that a config option if CodeMirror can do it? Or a
>>>>>> different hotkey?
>>>>>>
>>>>>>
>>>>> I'll check the extension code and update you accordingly, and It will
>>>>> be good idea to keep the both the options because with large code block
>>>>> current style works the best.
>>>>>
>>>>
>>>> Right.
>>>>
>>>>
>>>>> * You've added it as an option to the Clear XXX dropdown, which really
>>>>>> isn't the right place in my opinion. Should we add a new drop down for
>>>>>> this, and include some/all of the other Editing options on there? E.g.
>>>>>> tab/shift-tab.
>>>>>>
>>>>>> I thought that is misc options dropdown for our editor, but I don't
>>>>> see any point adding new drop down for one single option, Can we add new
>>>>> button instead?
>>>>>
>>>>
>>>> I think you missed this bit:  "and include some/all of the other
>>>> Editing options on there? E.g. tab/shift-tab.". Essentially, we'd be adding
>>>> an Edit menu...
>>>>
>>>>
>>>>> * I think the docs should say Ctrl+Shift+/ rather than Shift+Ctrl+/,
>>>>>> and be ordered in the table to reflect that. It seems more natural to me.
>>>>>>
>>>>>> Initially I wrote ctrl + shift + /only but when I saw all other
>>>>> shortcuts starts with Shift , then I changed it to shift + ctrl + / :)
>>>>>
>>>>
>>>> No they don't - Ctrl+Alt+Left for example. I believe it's normal to put
>>>> Ctrl first, then Shift as it's a modifier.
>>>>
>>>>
>>>>> Thoughts?
>>>>>>
>>>>>> --
>>>>>> 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]: Allow user to Comment/Uncomment code in query editor

2017-07-19 Thread Murtuza Zabuawala
Sure, Will take a look.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jul 19, 2017 at 8:00 PM, Dave Page  wrote:

> Except I managed to break a couple of tests :-(. Can you take a look
> please? I've had some other work come up that I need to deal with.
>
> ==
> ERROR: runTest (pgadmin.feature_tests.query_tool_journey_test.
> QueryToolJourneyTest)
> Tests the path through the query tool
> --
> Traceback (most recent call last):
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
> line 45, in runTest
> self._test_history_tab()
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
> line 71, in _test_history_tab
> self.__clear_query_tool()
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
> line 91, in __clear_query_tool
> self.page.click_element(self.page.find_by_xpath("//*[@id='
> btn-edit']"))
>   File 
> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 148, in find_by_xpath
> return self.wait_for_element(lambda driver:
> driver.find_element_by_xpath(xpath))
>   File 
> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 232, in wait_for_element
> return self._wait_for("element to exist", element_if_it_exists)
>   File 
> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 282, in _wait_for
> "Timed out waiting for " + waiting_for_message)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/selenium/webdriver/support/wait.py", line 80, in until
> raise TimeoutException(message, screen, stacktrace)
> TimeoutException: Message: Timed out waiting for element to exist
>
>
> ==
> 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_tool_tests.py",
> line 52, in runTest
> self._clear_query_tool()
>   File 
> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_tests.py",
> line 173, in _clear_query_tool
> self.page.find_by_id("btn-edit").click()
>   File 
> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 151, in find_by_id
> return self.wait_for_element(lambda driver: driver.find_element_by_id(
> element_id))
>   File 
> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 232, in wait_for_element
> return self._wait_for("element to exist", element_if_it_exists)
>   File 
> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
> line 282, in _wait_for
> "Timed out waiting for " + waiting_for_message)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/selenium/webdriver/support/wait.py", line 80, in until
> raise TimeoutException(message, screen, stacktrace)
> TimeoutException: Message: Timed out waiting for element to exist
>
>
> --
> Ran 9 tests in 262.111s
>
> On Wed, Jul 19, 2017 at 11:55 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Thank you Dave.
>>
>> On Wed, Jul 19, 2017 at 4:17 PM, Dave Page  wrote:
>>
>>> Thanks, applied.
>>>
>>> I also took the opportunity to tidy up the menus a little and add access
>>> keys for accessibility.
>>>
>>> One change I made was to make the Edit and Clear menus not have a
>>> default option - e.g. instead of a button with a drop-down next to it,
>>> they're now a single dropdown button with icon. I think this works better
>>> as there are no obvious candidates for the "default" option for those
>>> menus. I'm not overly enthusiastic about the look of those buttons though,
>>> so if anyone has a better idea how they should be styled, please yelp
>>> (CCing Chethana for his input as well)...
>>>
>>>
>>>
>>> On Wed, Jul 19, 2017 at 9:56 AM, Murtuza Zabuawala <
>>>

[pgAdmin4][Patch]: To make session more secure in web mode

2017-07-20 Thread Murtuza Zabuawala
Hi,

PFA minor patch to make session more secure in web mode.
RM#2584

Ref: https://flask-paranoid.readthedocs.io/en/latest/

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/requirements.txt b/requirements.txt
index cc00a8d..9baf999 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -41,3 +41,4 @@ sqlparse==0.1.19
 Werkzeug==0.9.6
 WTForms==2.0.2
 backports.csv==1.0.4; python_version <= '2.7'
+Flask-Paranoid==0.1.0
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 4389e96..fd03cc1 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -22,6 +22,7 @@ from flask_security import Security, SQLAlchemyUserDatastore
 from flask_mail import Mail
 from flask_security.utils import login_user
 from werkzeug.datastructures import ImmutableDict
+from flask_paranoid import Paranoid
 
 from pgadmin.utils import PgAdminModule, driver
 from pgadmin.utils.versioned_template_loader import VersionedTemplateLoader
@@ -285,6 +286,11 @@ def create_app(app_name=None):
 
 app.session_interface = create_session_interface(app)
 
+# Make the Session more secure against XSS & CSRF when running in web mode
+if config.SERVER_MODE:
+paranoid = Paranoid(app)
+paranoid.redirect_view = 'browser.index'
+
 ##
 # Load all available server drivers
 ##


Re: [pgAdmin4][Patch]: To make session more secure in web mode

2017-07-20 Thread Murtuza Zabuawala
It is based on Flask-Login module but
1) Flask-Login will mark a user as logged out when it detects that an
existing session suddenly appears to come from a different originating IP
address or a different browser. But it is unfortunate that Flask-Login does
not enable this option by default.
2) It does not support it at all if you want to also use the browsers
"remember me" functionality.

It's just a small wrapper module to overcome above scenarios, It is not
most necessary thing to include in our project but it will improve the
session security.

On Thu, Jul 20, 2017 at 5:52 PM, Dave Page  wrote:

> Hi
>
> On Thu, Jul 20, 2017 at 12:59 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Tested it with PEM7 RestApi testsuite and it is working fine :)
>>
>
> The docs for this module say it's based on Flask-Login's session protect
> mechanism, and was intended to allow session protection in other scenarios.
> As we are already using Flask-Login, do we need this?
>
> See the Session Protection section on https://flask-login.
> readthedocs.io/en/latest/.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-20 Thread Murtuza Zabuawala
Hi Dave,

I am working on this, will send you patch soon.

On Thu, Jul 20, 2017 at 5:53 PM, Dave Page  wrote:

> Did you get a chance to look at this yet Murtuza?
>
> On Wed, Jul 19, 2017 at 3:37 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Sure, Will take a look.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Wed, Jul 19, 2017 at 8:00 PM, Dave Page  wrote:
>>
>>> Except I managed to break a couple of tests :-(. Can you take a look
>>> please? I've had some other work come up that I need to deal with.
>>>
>>> ==
>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>> ool_journey_test.QueryToolJourneyTest)
>>> Tests the path through the query tool
>>> --
>>> Traceback (most recent call last):
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>> line 45, in runTest
>>> self._test_history_tab()
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>> line 71, in _test_history_tab
>>> self.__clear_query_tool()
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>> line 91, in __clear_query_tool
>>> self.page.click_element(self.page.find_by_xpath("//*[@id='bt
>>> n-edit']"))
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>> line 148, in find_by_xpath
>>> return self.wait_for_element(lambda driver:
>>> driver.find_element_by_xpath(xpath))
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>> line 232, in wait_for_element
>>> return self._wait_for("element to exist", element_if_it_exists)
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>> line 282, in _wait_for
>>> "Timed out waiting for " + waiting_for_message)
>>>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/support/wait.py", line 80, in until
>>> raise TimeoutException(message, screen, stacktrace)
>>> TimeoutException: Message: Timed out waiting for element to exist
>>>
>>>
>>> ==
>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>> ool_tests.QueryToolFeatureTest)
>>> Query tool feature test
>>> --
>>> Traceback (most recent call last):
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_tests.py",
>>> line 52, in runTest
>>> self._clear_query_tool()
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_tests.py",
>>> line 173, in _clear_query_tool
>>> self.page.find_by_id("btn-edit").click()
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>> line 151, in find_by_id
>>> return self.wait_for_element(lambda driver:
>>> driver.find_element_by_id(element_id))
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>> line 232, in wait_for_element
>>> return self._wait_for("element to exist", element_if_it_exists)
>>>   File 
>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>> line 282, in _wait_for
>>> "Timed out waiting for " + waiting_for_message)
>>>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>> ges/selenium/webdriver/support/wait.py", line 80, in until
>>> raise TimeoutException(message, screen, stacktrace)
>>> TimeoutException: Message: Timed out waiting for element to exist
>>>
>>>
>>> ----------
>>> Ran 9 tests in 262.111s
>>>
>>> On Wed, Jul 19, 2017 at 11:55 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@

Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-20 Thread Murtuza Zabuawala
Hi Dave,

Please find patch attached, There were two issues,
1) We removed the default button to clear the editor window, it
broke _clear_query_tool() functionality.
2) The buttons arrangements, we added new Edit button in between Delete and
Filter button causing the "Explain" -> "Explain Options" sub menu to go out
of browser visibility in feature test, so it was failing.

I have put Edit button near Clear button for now, until we come up with new
design for our editor for displaying these options.


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Jul 20, 2017 at 6:04 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> I am working on this, will send you patch soon.
>
> On Thu, Jul 20, 2017 at 5:53 PM, Dave Page  wrote:
>
>> Did you get a chance to look at this yet Murtuza?
>>
>> On Wed, Jul 19, 2017 at 3:37 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Sure, Will take a look.
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Wed, Jul 19, 2017 at 8:00 PM, Dave Page  wrote:
>>>
>>>> Except I managed to break a couple of tests :-(. Can you take a look
>>>> please? I've had some other work come up that I need to deal with.
>>>>
>>>> ==
>>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>>> ool_journey_test.QueryToolJourneyTest)
>>>> Tests the path through the query tool
>>>> --
>>>> Traceback (most recent call last):
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>> line 45, in runTest
>>>> self._test_history_tab()
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>> line 71, in _test_history_tab
>>>> self.__clear_query_tool()
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>> line 91, in __clear_query_tool
>>>> self.page.click_element(self.page.find_by_xpath("//*[@id='bt
>>>> n-edit']"))
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>> line 148, in find_by_xpath
>>>> return self.wait_for_element(lambda driver:
>>>> driver.find_element_by_xpath(xpath))
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>> line 232, in wait_for_element
>>>> return self._wait_for("element to exist", element_if_it_exists)
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>> line 282, in _wait_for
>>>> "Timed out waiting for " + waiting_for_message)
>>>>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>>> ges/selenium/webdriver/support/wait.py", line 80, in until
>>>> raise TimeoutException(message, screen, stacktrace)
>>>> TimeoutException: Message: Timed out waiting for element to exist
>>>>
>>>>
>>>> ==
>>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>>> ool_tests.QueryToolFeatureTest)
>>>> Query tool feature test
>>>> --
>>>> Traceback (most recent call last):
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_tests.py",
>>>> line 52, in runTest
>>>> self._clear_query_tool()
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_tests.py",
>>>> line 173, in _clear_query_tool
>>>> self.page.find_by_id("btn-edit").click()
>>>>   File 
>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>> line 151, in find_by_id
>>>> return self.wait_for_element(lambda driver:
>>>> driver.fi

Re: [pgAdmin4][Patch]: To make session more secure in web mode

2017-07-20 Thread Murtuza Zabuawala
On Thu, Jul 20, 2017 at 6:17 PM, Dave Page  wrote:

>
>
> On Thu, Jul 20, 2017 at 1:34 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> It is based on Flask-Login module but
>> 1) Flask-Login will mark a user as logged out when it detects that an
>> existing session suddenly appears to come from a different originating IP
>> address or a different browser. But it is unfortunate that Flask-Login does
>> not enable this option by default.
>>
>
> That's just a config change though, to use strong protection instead of
> basic.
>
>
Yes we can set it to "strong" but then user won't be able to use "Remember
me" functionality as it won't support it with "strong" protection.

> 2) It does not support it at all if you want to also use the browsers
>> "remember me" functionality.
>>
>
> The *browsers* remember me functionality, or Flasks? AFAIK remember me in
> the browser is just auto-filling of the username/password anyway, which
> will only happen when creating a new session right?
>
> Browsers.

>
>
>>
>> It's just a small wrapper module to overcome above scenarios, It is not
>> most necessary thing to include in our project but it will improve the
>> session security.
>>
>> On Thu, Jul 20, 2017 at 5:52 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thu, Jul 20, 2017 at 12:59 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> Tested it with PEM7 RestApi testsuite and it is working fine :)
>>>>
>>>
>>> The docs for this module say it's based on Flask-Login's session protect
>>> mechanism, and was intended to allow session protection in other scenarios.
>>> As we are already using Flask-Login, do we need this?
>>>
>>> See the Session Protection section on https://flask-login.readthe
>>> docs.io/en/latest/.
>>>
>>> --
>>> 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: Unified server/desktop config

2017-07-20 Thread Murtuza Zabuawala
Hi Dave,

Partial patch for feature test got included in you patch :)


On Thu, Jul 20, 2017 at 9:33 PM, Dave Page  wrote:

> All,
>
> Attached is a patch that aims to allow us to have a standardised config
> that will work out of the box for both web and desktop modes. It does this
> by doing two things:
>
> 1) The runtime sets SERVER_MODE in the Python environment before starting
> the app. If this value is set, then it overrides the default value of
> SERVER_MODE in the config.
>
> 2) The config file then offers default values for the various file
> locations for both server and desktop mode, setting them appropriately
> based on the derived SERVER_MODE value.
>
> The only downsides I can see from this are:
>
> - You cannot run in server mode in the runtime without manually
> reconfiguring SERVER_MODE and likely a bunch of paths in config_local.py
>
> - If you want to override SERVER_MODE, you'll probably also need to
> redefine the various paths in config_local.py.
>
> I don't see either being something 99.9% of users would need though.
>
> Can anyone see if the patch breaks anything, or if I missed any side
> effects?
>
> Is it likely to break things during upgrades? I suspect so... so maybe
> this should prompt v2.0?
>
> I'd appreciate multiple reviews of this, as it could break things. Note
> that I haven't yet updated the docs.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: Unified server/desktop config

2017-07-20 Thread Murtuza Zabuawala
Oops sorry my bad, I did not removed it.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Thu, Jul 20, 2017 at 10:22 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> Partial patch for feature test got included in you patch :)
>
>
> On Thu, Jul 20, 2017 at 9:33 PM, Dave Page  wrote:
>
>> All,
>>
>> Attached is a patch that aims to allow us to have a standardised config
>> that will work out of the box for both web and desktop modes. It does this
>> by doing two things:
>>
>> 1) The runtime sets SERVER_MODE in the Python environment before starting
>> the app. If this value is set, then it overrides the default value of
>> SERVER_MODE in the config.
>>
>> 2) The config file then offers default values for the various file
>> locations for both server and desktop mode, setting them appropriately
>> based on the derived SERVER_MODE value.
>>
>> The only downsides I can see from this are:
>>
>> - You cannot run in server mode in the runtime without manually
>> reconfiguring SERVER_MODE and likely a bunch of paths in config_local.py
>>
>> - If you want to override SERVER_MODE, you'll probably also need to
>> redefine the various paths in config_local.py.
>>
>> I don't see either being something 99.9% of users would need though.
>>
>> Can anyone see if the patch breaks anything, or if I missed any side
>> effects?
>>
>> Is it likely to break things during upgrades? I suspect so... so maybe
>> this should prompt v2.0?
>>
>> I'd appreciate multiple reviews of this, as it could break things. Note
>> that I haven't yet updated the docs.
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-20 Thread Murtuza Zabuawala
On Thu, Jul 20, 2017 at 10:29 PM, Dave Page  wrote:

> Hi
>
> On Thu, Jul 20, 2017 at 3:33 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find patch attached, There were two issues,
>> 1) We removed the default button to clear the editor window, it
>> broke _clear_query_tool() functionality.
>> 2) The buttons arrangements, we added new Edit button in between Delete
>> and Filter button causing the "Explain" -> "Explain Options" sub menu to go
>> out of browser visibility in feature test, so it was failing.
>>
>> I have put Edit button near Clear button for now, until we come up with
>> new design for our editor for displaying these options.
>>
>
> Hmm, I moved it there intentionally as it's a more traditional position
> and thus more discoverable.
>
> Can we just launch the browser with a wider size, say, 1280? It's on line
> 43 of app_starter.py...
>
>
Yes, that will work too.

>
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Thu, Jul 20, 2017 at 6:04 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> I am working on this, will send you patch soon.
>>>
>>> On Thu, Jul 20, 2017 at 5:53 PM, Dave Page  wrote:
>>>
>>>> Did you get a chance to look at this yet Murtuza?
>>>>
>>>> On Wed, Jul 19, 2017 at 3:37 PM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> Sure, Will take a look.
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Murtuza Zabuawala
>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>> On Wed, Jul 19, 2017 at 8:00 PM, Dave Page  wrote:
>>>>>
>>>>>> Except I managed to break a couple of tests :-(. Can you take a look
>>>>>> please? I've had some other work come up that I need to deal with.
>>>>>>
>>>>>> 
>>>>>> ==
>>>>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>>>>> ool_journey_test.QueryToolJourneyTest)
>>>>>> Tests the path through the query tool
>>>>>> 
>>>>>> --
>>>>>> Traceback (most recent call last):
>>>>>>   File 
>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>> line 45, in runTest
>>>>>> self._test_history_tab()
>>>>>>   File 
>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>> line 71, in _test_history_tab
>>>>>> self.__clear_query_tool()
>>>>>>   File 
>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>> line 91, in __clear_query_tool
>>>>>> self.page.click_element(self.page.find_by_xpath("//*[@id='bt
>>>>>> n-edit']"))
>>>>>>   File 
>>>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>>>> line 148, in find_by_xpath
>>>>>> return self.wait_for_element(lambda driver:
>>>>>> driver.find_element_by_xpath(xpath))
>>>>>>   File 
>>>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>>>> line 232, in wait_for_element
>>>>>> return self._wait_for("element to exist", element_if_it_exists)
>>>>>>   File 
>>>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>>>> line 282, in _wait_for
>>>>>> "Timed out waiting for " + waiting_for_message)
>>>>>>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa
>>>>>> ges/selenium/webdriver/support/wait.py", line 80, in until
>>>>>> raise TimeoutException(message, screen, stacktrace)
>>>>>> TimeoutException: Messa

Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-21 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch.

On Thu, Jul 20, 2017 at 10:35 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

>
> On Thu, Jul 20, 2017 at 10:29 PM, Dave Page  wrote:
>
>> Hi
>>
>> On Thu, Jul 20, 2017 at 3:33 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> Please find patch attached, There were two issues,
>>> 1) We removed the default button to clear the editor window, it
>>> broke _clear_query_tool() functionality.
>>> 2) The buttons arrangements, we added new Edit button in between Delete
>>> and Filter button causing the "Explain" -> "Explain Options" sub menu to go
>>> out of browser visibility in feature test, so it was failing.
>>>
>>> I have put Edit button near Clear button for now, until we come up with
>>> new design for our editor for displaying these options.
>>>
>>
>> Hmm, I moved it there intentionally as it's a more traditional position
>> and thus more discoverable.
>>
>> Can we just launch the browser with a wider size, say, 1280? It's on line
>> 43 of app_starter.py...
>>
>>
> Yes, that will work too.
>
>>
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Thu, Jul 20, 2017 at 6:04 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> I am working on this, will send you patch soon.
>>>>
>>>> On Thu, Jul 20, 2017 at 5:53 PM, Dave Page  wrote:
>>>>
>>>>> Did you get a chance to look at this yet Murtuza?
>>>>>
>>>>> On Wed, Jul 19, 2017 at 3:37 PM, Murtuza Zabuawala <
>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>
>>>>>> Sure, Will take a look.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Murtuza Zabuawala
>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Wed, Jul 19, 2017 at 8:00 PM, Dave Page  wrote:
>>>>>>
>>>>>>> Except I managed to break a couple of tests :-(. Can you take a look
>>>>>>> please? I've had some other work come up that I need to deal with.
>>>>>>>
>>>>>>> 
>>>>>>> ==
>>>>>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>>>>>> ool_journey_test.QueryToolJourneyTest)
>>>>>>> Tests the path through the query tool
>>>>>>> 
>>>>>>> --
>>>>>>> Traceback (most recent call last):
>>>>>>>   File 
>>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>>> line 45, in runTest
>>>>>>> self._test_history_tab()
>>>>>>>   File 
>>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>>> line 71, in _test_history_tab
>>>>>>> self.__clear_query_tool()
>>>>>>>   File 
>>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>>> line 91, in __clear_query_tool
>>>>>>> self.page.click_element(self.page.find_by_xpath("//*[@id='bt
>>>>>>> n-edit']"))
>>>>>>>   File 
>>>>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>>>>> line 148, in find_by_xpath
>>>>>>> return self.wait_for_element(lambda driver:
>>>>>>> driver.find_element_by_xpath(xpath))
>>>>>>>   File 
>>>>>>> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/pgadmin_page.py",
>>>>>>> line 232, in wait_for_element
>>>>>>> return self._wait_for("element to exist", element_if_it_exists)
>>>>>>>   File 
>>>>&g

Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-21 Thread Murtuza Zabuawala
Hi Robert,

Just to make shortcut keys uniform across all the platforms.

On Fri, Jul 21, 2017 at 1:25 AM, Robert Eckhardt 
wrote:

> Murtuza,
>
> Is there a particular reason you choose the keyboard shortcuts that you
> choose. When we were looking at this earlier to see what was being used
> elsewhere we discovered:
>
> jetbrains  cmd+/
> pycharmcmd+/
> SublimeCtrl+/ Toggle line comment
>Ctrl+Shift+/ Toggle block comment
> EclipseCTRL + /
> Notepad++  CTRL+Q   Toggle line comment
>CTRL+SHIFT+Q Toggle block comment
> TextWrangler   Ctrl+/
>
> -- Rob
>
>
> On Thu, Jul 20, 2017 at 1:05 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>>
>> On Thu, Jul 20, 2017 at 10:29 PM, Dave Page  wrote:
>>
>>> Hi
>>>
>>> On Thu, Jul 20, 2017 at 3:33 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> Please find patch attached, There were two issues,
>>>> 1) We removed the default button to clear the editor window, it
>>>> broke _clear_query_tool() functionality.
>>>> 2) The buttons arrangements, we added new Edit button in between Delete
>>>> and Filter button causing the "Explain" -> "Explain Options" sub menu to go
>>>> out of browser visibility in feature test, so it was failing.
>>>>
>>>> I have put Edit button near Clear button for now, until we come up with
>>>> new design for our editor for displaying these options.
>>>>
>>>
>>> Hmm, I moved it there intentionally as it's a more traditional position
>>> and thus more discoverable.
>>>
>>> Can we just launch the browser with a wider size, say, 1280? It's on
>>> line 43 of app_starter.py...
>>>
>>>
>> Yes, that will work too.
>>
>>>
>>>>
>>>> --
>>>> Regards,
>>>> Murtuza Zabuawala
>>>> EnterpriseDB: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> On Thu, Jul 20, 2017 at 6:04 PM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Dave,
>>>>>
>>>>> I am working on this, will send you patch soon.
>>>>>
>>>>> On Thu, Jul 20, 2017 at 5:53 PM, Dave Page  wrote:
>>>>>
>>>>>> Did you get a chance to look at this yet Murtuza?
>>>>>>
>>>>>> On Wed, Jul 19, 2017 at 3:37 PM, Murtuza Zabuawala <
>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Sure, Will take a look.
>>>>>>>
>>>>>>> --
>>>>>>> Regards,
>>>>>>> Murtuza Zabuawala
>>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>> On Wed, Jul 19, 2017 at 8:00 PM, Dave Page 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Except I managed to break a couple of tests :-(. Can you take a
>>>>>>>> look please? I've had some other work come up that I need to deal with.
>>>>>>>>
>>>>>>>> 
>>>>>>>> ==
>>>>>>>> ERROR: runTest (pgadmin.feature_tests.query_t
>>>>>>>> ool_journey_test.QueryToolJourneyTest)
>>>>>>>> Tests the path through the query tool
>>>>>>>> 
>>>>>>>> --
>>>>>>>> Traceback (most recent call last):
>>>>>>>>   File 
>>>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>>>> line 45, in runTest
>>>>>>>> self._test_history_tab()
>>>>>>>>   File 
>>>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
>>>>>>>> line 71, in _test_history_tab
>>>>>>>> self.__clear_query_tool()
>>>>>>>>   File 
>>>>>>>> "/Users/dpage/git/pgadmin4/web/pgadmin/

[pgAdmin4][Patch]: To fix database disconnect option

2017-07-21 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where database disconnect option is not
working.

*Steps to re-produce:*
1) Create a "test" database
2) Connect to "test" database
3) Right click on "test" database and try to disconnect it, you will get an
error on console.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js 
b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
index d2d4c48..2b9f052 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
@@ -173,11 +173,11 @@ define('pgadmin.node.database', [
 },
 /* Disconnect the database */
 disconnect_database: function(args) {
-  var input = args || {};
-  obj = this,
-  t = pgBrowser.tree,
-  i = input.item || t.selected(),
-  d = i && i.length == 1 ? t.itemData(i) : undefined;
+  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;
@@ -192,8 +192,8 @@ define('pgadmin.node.database', [
 type:'DELETE',
 success: function(res) {
   if (res.success == 1) {
-var prv_i = t.parent(i);
-var alertifyWrapper = new AlertifyWrapper();
+var prv_i = t.parent(i),
+  alertifyWrapper = new AlertifyWrapper();
 alertifyWrapper.success(res.info);
 t.removeIcon(i);
 data.connected = false;


Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-21 Thread Murtuza Zabuawala
Hi Robert,

I mean rather than using cmd key for Mac and CTRL key for Windows/Linux, I
used "CTRL" key for all the platforms.
And regarding choosing comma & period keys, they all are near each to each
other so user can remember them easily.

Let me know If my thinking was wrong for shortcut keys, I'll change them
accordingly and send new patch.

On Fri, Jul 21, 2017 at 4:25 PM, Robert Eckhardt 
wrote:

> I'm not sure what you mean by across platforms.  Do you mean that those
> are the keyboard shortcuts in pgAdmin 3?
>
> Rob
>
> On Jul 21, 2017 4:42 AM, "Murtuza Zabuawala"  enterprisedb.com> wrote:
>
> Hi Robert,
>
> Just to make shortcut keys uniform across all the platforms.
>
> On Fri, Jul 21, 2017 at 1:25 AM, Robert Eckhardt 
> wrote:
>
>> Murtuza,
>>
>> Is there a particular reason you choose the keyboard shortcuts that you
>> choose. When we were looking at this earlier to see what was being used
>> elsewhere we discovered:
>>
>> jetbrains  cmd+/
>> pycharmcmd+/
>> SublimeCtrl+/ Toggle line comment
>>Ctrl+Shift+/ Toggle block comment
>> EclipseCTRL + /
>> Notepad++  CTRL+Q   Toggle line comment
>>CTRL+SHIFT+Q Toggle block comment
>> TextWrangler   Ctrl+/
>>
>> -- Rob
>>
>>
>> On Thu, Jul 20, 2017 at 1:05 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>>
>>> On Thu, Jul 20, 2017 at 10:29 PM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> On Thu, Jul 20, 2017 at 3:33 PM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Dave,
>>>>>
>>>>> Please find patch attached, There were two issues,
>>>>> 1) We removed the default button to clear the editor window, it
>>>>> broke _clear_query_tool() functionality.
>>>>> 2) The buttons arrangements, we added new Edit button in between
>>>>> Delete and Filter button causing the "Explain" -> "Explain Options" sub
>>>>> menu to go out of browser visibility in feature test, so it was failing.
>>>>>
>>>>> I have put Edit button near Clear button for now, until we come up
>>>>> with new design for our editor for displaying these options.
>>>>>
>>>>
>>>> Hmm, I moved it there intentionally as it's a more traditional position
>>>> and thus more discoverable.
>>>>
>>>> Can we just launch the browser with a wider size, say, 1280? It's on
>>>> line 43 of app_starter.py...
>>>>
>>>>
>>> Yes, that will work too.
>>>
>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Murtuza Zabuawala
>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>> On Thu, Jul 20, 2017 at 6:04 PM, Murtuza Zabuawala <
>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi Dave,
>>>>>>
>>>>>> I am working on this, will send you patch soon.
>>>>>>
>>>>>> On Thu, Jul 20, 2017 at 5:53 PM, Dave Page  wrote:
>>>>>>
>>>>>>> Did you get a chance to look at this yet Murtuza?
>>>>>>>
>>>>>>> On Wed, Jul 19, 2017 at 3:37 PM, Murtuza Zabuawala <
>>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Sure, Will take a look.
>>>>>>>>
>>>>>>>> --
>>>>>>>> Regards,
>>>>>>>> Murtuza Zabuawala
>>>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>
>>>>>>>> On Wed, Jul 19, 2017 at 8:00 PM, Dave Page 
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Except I managed to break a couple of tests :-(. Can you take a
>>>>>>>>> look please? I've had some other work come up that I need to deal 
>>>>>>>>> with.
>>>>>>>>>
>>>>>>>>> 
>>>>>>>>> ==

Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-24 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch.

On Tue, Jul 18, 2017 at 8:05 PM, Murtuza Zabuawala  wrote:

> Hi Shirley,
>
> On Tue, Jul 18, 2017 at 1:21 AM, Shirley Wang  wrote:
>
>> Hi!
>>
>> I can't seem to get the patch to completely work on my computer, only the
>> close icon shows up plus the dialog and success/error messages, but here
>> are some comments:
>>
>> Because  we are just cancelling the active running query, so if the start
> of the session is 'Active' when you cancel it will simply goto 'Idle' stat.
>
>> +1 to Dave's comment about refreshing after the cancel operation
>>
>> I'll fix this.
>
>> - We're working on a patch for updating alerts in the Dashboard tab which
>> updates the grays in the Database activities panel and changes the border
>> around the refresh button and search bar to 1px. This hasn't been submitted
>> yet but just a heads up as you work on the alignment.
>>
>> - Something to consider is how a super user will identify which session
>> should be closed. Is that information there?
>>
>> I think super user can cancel everything except main connection session &
> as Dave mentioned in previous email that background workers in PG10.
>
>> - Are there sessions that should never be closed? If so, do they also
>> need close buttons? (Probably not, because that will lead the user to an
>> error message, which is not fun)
>>
>> In Backgrid, we can not exclude specific column from certain rows if it
> renders in one row then it will render for every row in the grid, What we
> can do is, it will throw an error when user is not eligible to cancel the
> active running query.
>
>> - Perhaps this is a good feature to review with Chethana! :)
>>
>> On Mon, Jul 17, 2017 at 5:37 AM Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> On Mon, Jul 17, 2017 at 3:01 PM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> On Thu, Jul 13, 2017 at 2:53 PM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> hiHi,
>>>>>
>>>>> PFA patch to add functionality which will allow super user to cancel
>>>>> long running queries from dashboard.
>>>>> RM#1812
>>>>>
>>>>> *Steps used to test:*
>>>>> 1) Open psql session, Connect to 'test' database on respective server
>>>>> 2) Execute "select pg_sleep(1000);"
>>>>> 3) Open pgAdmin4
>>>>> 4) Connect to respective server
>>>>> 5) Click on Dashboard
>>>>> 6) Check "Sessions" tab under "Server activity" section then look for
>>>>> active sessions for test database.
>>>>> 7) Click on cancel button and cancel the active session
>>>>> 8) Check psql session now, you will see "ERROR:  canceling statement
>>>>> due to user request"
>>>>>
>>>>> Some comments:
>>>>
>>>> - The action here is to cancel the active query in the backend, not the
>>>> session - so messages etc. should say things like "Cancel Active Query?"
>>>>
>>>>
>>> - The grid should refresh following the cancel operation.
>>>>
>>>> - Can you fix the vertical alignment while you're working on this? The
>>>> new button really makes the poor alignment stand out.
>>>>
>>>> - This should not be superuser only - regular users should be able to
>>>> cancel their own queries.
>>>>
>>>> - On PG10, background workers are also shown in the dashboard. Should
>>>> we prevent attempts to cancel their work (they'll fail anyway I believe).
>>>>
>>>> Thanks!
>>>>
>>>>
>>> Sure, I'll work on these comments & send updated 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/dashboard/__init__.py 
b/web/pgadmin/dashboard/__init__.py
index b91ccb2..a4c18c9 100644
--- a/web/pgadmin/dashboard/__init__.py
+++ b/web/pgadmin/dashboard/__init__.py
@@ -456,3 +456,30 @@ def config(sid=None):
 :return:
 """
 return get_data(sid, None, 'config.sql')
+
+

Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-24 Thread Murtuza Zabuawala
Hi Dave,

On Mon, Jul 24, 2017 at 4:44 PM, Dave Page  wrote:

> Thanks, applied.
>
> How much effort do you think it would take to turn the table into a
> subnode control so we can show the SQL query and other missing fields from
> pg_stat_activity on that tab?
>
I think around 2-3 days would be needed.

>
>
On Mon, Jul 24, 2017 at 11:45 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Please find updated patch.
>>
>> On Tue, Jul 18, 2017 at 8:05 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Shirley,
>>>
>>> On Tue, Jul 18, 2017 at 1:21 AM, Shirley Wang  wrote:
>>>
>>>> Hi!
>>>>
>>>> I can't seem to get the patch to completely work on my computer, only
>>>> the close icon shows up plus the dialog and success/error messages, but
>>>> here are some comments:
>>>>
>>>> Because  we are just cancelling the active running query, so if the
>>> start of the session is 'Active' when you cancel it will simply goto 'Idle'
>>> stat.
>>>
>>>> +1 to Dave's comment about refreshing after the cancel operation
>>>>
>>>> I'll fix this.
>>>
>>>> - We're working on a patch for updating alerts in the Dashboard tab
>>>> which updates the grays in the Database activities panel and changes the
>>>> border around the refresh button and search bar to 1px. This hasn't been
>>>> submitted yet but just a heads up as you work on the alignment.
>>>>
>>>> - Something to consider is how a super user will identify which session
>>>> should be closed. Is that information there?
>>>>
>>>> I think super user can cancel everything except main connection session
>>> & as Dave mentioned in previous email that background workers in PG10.
>>>
>>>> - Are there sessions that should never be closed? If so, do they also
>>>> need close buttons? (Probably not, because that will lead the user to an
>>>> error message, which is not fun)
>>>>
>>>> In Backgrid, we can not exclude specific column from certain rows if it
>>> renders in one row then it will render for every row in the grid, What we
>>> can do is, it will throw an error when user is not eligible to cancel the
>>> active running query.
>>>
>>>> - Perhaps this is a good feature to review with Chethana! :)
>>>>
>>>> On Mon, Jul 17, 2017 at 5:37 AM Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> On Mon, Jul 17, 2017 at 3:01 PM, Dave Page  wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> On Thu, Jul 13, 2017 at 2:53 PM, Murtuza Zabuawala <
>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> hiHi,
>>>>>>>
>>>>>>> PFA patch to add functionality which will allow super user to cancel
>>>>>>> long running queries from dashboard.
>>>>>>> RM#1812
>>>>>>>
>>>>>>> *Steps used to test:*
>>>>>>> 1) Open psql session, Connect to 'test' database on respective server
>>>>>>> 2) Execute "select pg_sleep(1000);"
>>>>>>> 3) Open pgAdmin4
>>>>>>> 4) Connect to respective server
>>>>>>> 5) Click on Dashboard
>>>>>>> 6) Check "Sessions" tab under "Server activity" section then look
>>>>>>> for active sessions for test database.
>>>>>>> 7) Click on cancel button and cancel the active session
>>>>>>> 8) Check psql session now, you will see "ERROR:  canceling statement
>>>>>>> due to user request"
>>>>>>>
>>>>>>> Some comments:
>>>>>>
>>>>>> - The action here is to cancel the active query in the backend, not
>>>>>> the session - so messages etc. should say things like "Cancel Active 
>>>>>> Query?"
>>>>>>
>>>>>>
>>>>> - The grid should refresh following the cancel operation.
>>>>>>
>>>>>> - Can you fix the vertical alignment while you're working on this?
>>>>>> The new button really makes the poor alignment stand out.
>>>>>>
>>>>>> - This should not be superuser only - regular users should be able to
>>>>>> cancel their own queries.
>>>>>>
>>>>>> - On PG10, background workers are also shown in the dashboard. Should
>>>>>> we prevent attempts to cancel their work (they'll fail anyway I believe).
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>>
>>>>> Sure, I'll work on these comments & send updated patch.
>>>>>
>>>>>> --
>>>>>> 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]: Allow user to cancel long running queries from dashboard

2017-07-24 Thread Murtuza Zabuawala
Sure.

RM created: https://redmine.postgresql.org/issues/2597.

On Mon, Jul 24, 2017 at 6:04 PM, Dave Page  wrote:

>
>
> On Mon, Jul 24, 2017 at 1:12 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> On Mon, Jul 24, 2017 at 4:44 PM, Dave Page  wrote:
>>
>>> Thanks, applied.
>>>
>>> How much effort do you think it would take to turn the table into a
>>> subnode control so we can show the SQL query and other missing fields from
>>> pg_stat_activity on that tab?
>>>
>> I think around 2-3 days would be needed.
>>
>
> OK - can you add a Redmine and work on that please? It's been a known
> deficiency for quite a while, and whilst working on this patch I realised
> just how badly we really need to see the SQL there.
>
> Thanks.
>
>
>>
>>>
>> On Mon, Jul 24, 2017 at 11:45 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> Please find updated patch.
>>>>
>>>> On Tue, Jul 18, 2017 at 8:05 PM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Shirley,
>>>>>
>>>>> On Tue, Jul 18, 2017 at 1:21 AM, Shirley Wang 
>>>>> wrote:
>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> I can't seem to get the patch to completely work on my computer, only
>>>>>> the close icon shows up plus the dialog and success/error messages, but
>>>>>> here are some comments:
>>>>>>
>>>>>> Because  we are just cancelling the active running query, so if the
>>>>> start of the session is 'Active' when you cancel it will simply goto 
>>>>> 'Idle'
>>>>> stat.
>>>>>
>>>>>> +1 to Dave's comment about refreshing after the cancel operation
>>>>>>
>>>>>> I'll fix this.
>>>>>
>>>>>> - We're working on a patch for updating alerts in the Dashboard tab
>>>>>> which updates the grays in the Database activities panel and changes the
>>>>>> border around the refresh button and search bar to 1px. This hasn't been
>>>>>> submitted yet but just a heads up as you work on the alignment.
>>>>>>
>>>>>> - Something to consider is how a super user will identify which
>>>>>> session should be closed. Is that information there?
>>>>>>
>>>>>> I think super user can cancel everything except main connection
>>>>> session & as Dave mentioned in previous email that background workers in
>>>>> PG10.
>>>>>
>>>>>> - Are there sessions that should never be closed? If so, do they also
>>>>>> need close buttons? (Probably not, because that will lead the user to an
>>>>>> error message, which is not fun)
>>>>>>
>>>>>> In Backgrid, we can not exclude specific column from certain rows if
>>>>> it renders in one row then it will render for every row in the grid, What
>>>>> we can do is, it will throw an error when user is not eligible to cancel
>>>>> the active running query.
>>>>>
>>>>>> - Perhaps this is a good feature to review with Chethana! :)
>>>>>>
>>>>>> On Mon, Jul 17, 2017 at 5:37 AM Murtuza Zabuawala <
>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> On Mon, Jul 17, 2017 at 3:01 PM, Dave Page 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> On Thu, Jul 13, 2017 at 2:53 PM, Murtuza Zabuawala <
>>>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>>>
>>>>>>>>> hiHi,
>>>>>>>>>
>>>>>>>>> PFA patch to add functionality which will allow super user
>>>>>>>>> to cancel long running queries from dashboard.
>>>>>>>>> RM#1812
>>>>>>>>>
>>>>>>>>> *Steps used to test:*
>>>>>>>>> 1) Open psql session, Connect to 'test' database on respective
>>>>>>>

[pgAdmin4][Patch]: Handle WSGI Alias while generating URL for endpoints.js

2017-07-25 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where user were not able to run pgAdmin4 under
WSGI Alias (example: localhost/pgadmin).
RM#2563

*Issue:*
- Removed hard coded url paths from base.html
- URL's are not generated with WSGI alias when we use
current_app.url_map.iter_rules() function to fetch all the endpoints and
their respective url's.

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 49c4fdd..0ca1c58 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -14,7 +14,7 @@ import os, sys
 from collections import defaultdict
 from importlib import import_module
 
-from flask import Flask, abort, request, current_app, session
+from flask import Flask, abort, request, current_app, session, url_for
 from flask_babel import Babel, gettext
 from flask_htmlmin import HTMLMIN
 from flask_login import user_logged_in
@@ -89,13 +89,39 @@ class PgAdmin(Flask):
 
 @property
 def exposed_endpoint_url_map(self):
+#
+# To handle WSGI paths
+# If user has setup application under WSGI alias
+# like 'localhost/pgadmin4' then we have to append '/pgadmin4'
+# into endpoints
+#
+import config
+is_wsgi_root_present = False
+if config.SERVER_MODE:
+pgadmin_root_path = url_for('browser.index')
+if pgadmin_root_path != '/browser/':
+is_wsgi_root_present = True
+wsgi_root_path = pgadmin_root_path.replace(
+'/browser/', ''
+)
+
+def get_full_url_path(url):
+"""
+Generate endpoint URL at per WSGI alias
+"""
+if is_wsgi_root_present and url:
+return wsgi_root_path + url
+else:
+return url
+
+# Fetch all endpoints and thier respective url
 for rule in current_app.url_map.iter_rules('static'):
-yield rule.endpoint, rule.rule
+yield rule.endpoint, get_full_url_path(rule.rule)
 
 for module in self.submodules:
 for endpoint in module.exposed_endpoints:
 for rule in current_app.url_map.iter_rules(endpoint):
-yield rule.endpoint, rule.rule
+yield rule.endpoint, get_full_url_path(rule.rule)
 
 @property
 def javascripts(self):
diff --git a/web/pgadmin/templates/base.html b/web/pgadmin/templates/base.html
index 87e3f78..f0d1703 100755
--- a/web/pgadmin/templates/base.html
+++ b/web/pgadmin/templates/base.html
@@ -41,14 +41,14 @@
 slickgrid: "{{ url_for('static', 
filename='js/generated/slickgrid') }}",
 codemirror: "{{ url_for('static', 
filename='js/generated/codemirror') }}",
 datagrid: "{{ url_for('static', 
filename='js/generated/datagrid') }}",
-sqleditor: "{{ url_for('static', 
filename='js/generated/sqleditor') }}"
-,'browser_node': "{{ url_for('static', 
filename='js/generated/browser_node') }}"
-,'pgadmin.browser.utils': "/browser/js/utils"
-,'pgadmin.browser.endpoints': "/browser/js/endpoints"
-,'pgadmin.browser.messages': "/browser/js/messages"
-,'pgadmin.server.supported_servers': 
"/browser/server/supported_servers"
-,'pgadmin.user_management.current_user': 
"/user_management/current_user"
-,'translations': "/tools/translations"
+sqleditor: "{{ url_for('static', 
filename='js/generated/sqleditor') }}",
+'browser_node': "{{ url_for('static', 
filename='js/generated/browser_node') }}",
+'pgadmin.browser.utils': "{{ url_for('browser.index') }}" 
+ "js/utils",
+'pgadmin.browser.endpoints': "{{ url_for('browser.index') 
}}" + "js/endpoints",
+'pgadmin.browser.messages': "{{ url_for('browser.index') 
}}" + "js/messages",
+'pgadmin.server.supported_servers': "{{ 
url_for('browser.index') }}" + "server/supported_servers",
+'pgadmin.user_management.current_user': "{{ 
url_for('user_management.index') }}" + "current_user",
+'translations': "{{ url_for('tools.index') }}" + 
"translations"
 }
 });
 


Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-26 Thread Murtuza Zabuawala
Hi Dave,

Please find updated patch for new shortcut keys, I have tested it on all
three major platforms (macOS, Linux & Windows with Chrome, FF & IE11
Browsers).

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jul 21, 2017 at 9:38 PM, Robert Eckhardt 
wrote:

> Right - we lose the ability to uncomment multiple levels though, which may
>> also be useful.
>>
>
> Well yes.
>
> I would argue that simplicity trumps potential use. I'd also argue that
> attempting to maintain consistency across environments (IDEs, etc. ) is
> advantageous. This was the philosophy we were going with when enabling
> excel like behavior (also why I'm not fully happy with how it is today).
>
> -- Rob
>
diff --git a/docs/en_US/keyboard_shortcuts.rst 
b/docs/en_US/keyboard_shortcuts.rst
index cd0938d..32f06f0 100644
--- a/docs/en_US/keyboard_shortcuts.rst
+++ b/docs/en_US/keyboard_shortcuts.rst
@@ -41,11 +41,11 @@ When using the syntax-highlighting SQL editors, the 
following shortcuts are avai
 
+--+--+-+
 | Ctrl+Alt+Right   | Cmd+Option+Right | Move right one word
 |
 
+--+--+-+
-| Ctrl+Shift+, | Ctrl+Shift+, | Comment selected code (Inline) 
 |
+| Ctrl+Shift+/ | Cmd+Shift+/  | Comment selected code (Inline) 
 |
 
+--+--+-+
-| Ctrl+Shift+. | Ctrl+Shift+. | Uncomment selected code 
(Inline)|
+| Ctrl+Shift+. | Cmd+Shift+.  | Uncomment selected code 
(Inline)|
 
+--+--+-+
-| Ctrl+Shift+/ | Ctrl+Shift+/ | Comment/Uncomment code (Block) 
 |
+| Ctrl+/   | Cmd+/| Comment/Uncomment code (Block) 
 |
 
+--+--+-+
 | Ctrl+A   | Cmd+A| Select all 
 |
 
+--+--+-+
diff --git a/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js 
b/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
index c117413..5d947d1 100644
--- a/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
+++ b/web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js
@@ -1,9 +1,9 @@
 const F5_KEY = 116,
   F7_KEY = 118,
   F8_KEY = 119,
-  COMMA_KEY = 188,
   PERIOD_KEY = 190,
-  FWD_SLASH_KEY = 191;
+  FWD_SLASH_KEY = 191,
+  IS_CMD_KEY = window.navigator.platform.search('Mac') != -1;
 
 function keyboardShortcuts(sqlEditorController, event) {
   if (sqlEditorController.isQueryRunning()) {
@@ -24,13 +24,16 @@ function keyboardShortcuts(sqlEditorController, event) {
   } else if (keyCode === F8_KEY) {
 event.preventDefault();
 sqlEditorController.download();
-  } else if (event.shiftKey && event.ctrlKey && keyCode === COMMA_KEY) {
+  } else if (((IS_CMD_KEY && event.metaKey) || (!IS_CMD_KEY && event.ctrlKey)) 
&&
+ event.shiftKey && keyCode === FWD_SLASH_KEY) {
 _stopEventPropagation();
 sqlEditorController.commentLineCode();
-  } else if (event.shiftKey && event.ctrlKey && keyCode === PERIOD_KEY) {
+  } else if (((IS_CMD_KEY && event.metaKey) || (!IS_CMD_KEY && event.ctrlKey)) 
&&
+ event.shiftKey && keyCode === PERIOD_KEY) {
 _stopEventPropagation();
 sqlEditorController.uncommentLineCode();
-  } else if (event.shiftKey && event.ctrlKey && keyCode === FWD_SLASH_KEY) {
+  } else if (((IS_CMD_KEY && event.metaKey) || (!IS_CMD_KEY && event.ctrlKey)) 
&&
+ keyCode === FWD_SLASH_KEY) {
 _stopEventPropagation();
 sqlEditorController.commentBlockCode();
   }
diff --git a/web/pgadmin/tools/datagrid/__init__.py 
b/web/pgadmin/tools/datagrid/__init__.py
index 08b01ab..d3a4a9d 100644
--- a/web/pgadmin/tools/datagrid/__init__.py
+++ b/web/pgadmin/tools/datagrid/__init__.py
@@ -15,6 +15,7 @@ import pickle
 import random
 
 from flask import Response, url_for, session, request, make_response
+from werkzeug.useragents import UserAgent
 from flask import current_app as app
 from flask_babel import gettext
 from flask_security import login_required
@@ -183,6 +184,9 @@ def panel(trans_id, is_query_tool, editor_title):
 else:
 sURL = None
 
+# We need client OS information to render correct Keyboard shortcuts
+user_agent = UserAgent(request.headers.get('User-Agent'))
+
 """
 Animations and transitions are not automatically GPU accelerated and by 
default u

Re: Build failed in Jenkins: pgadmin4-master-python26 #386

2017-07-26 Thread Murtuza Zabuawala
Looking into it.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jul 26, 2017 at 5:28 PM, pgAdmin 4 Jenkins 
wrote:

> See <https://jenkins.pgadmin.org/job/pgadmin4-master-python26/
> 386/display/redirect?page=changes>
>
> Changes:
>
> [Dave Page] Update keyboard shortcuts per discussion. Also, make the
> labels platform
>
> --
> [...truncated 357.97 KB...]
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 59 of 254 SUCCESS (0 secs
> / 1.953 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 60 of 254 SUCCESS (0 secs
> / 1.958 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 61 of 254 SUCCESS (0 secs
> / 1.964 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 62 of 254 SUCCESS (0 secs
> / 1.969 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 63 of 254 SUCCESS (0 secs
> / 1.974 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 64 of 254 SUCCESS (0 secs
> / 1.979 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 65 of 254 SUCCESS (0 secs
> / 1.988 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 66 of 254 SUCCESS (0 secs
> / 1.993 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 67 of 254 SUCCESS (0 secs
> / 1.997 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 68 of 254 SUCCESS (0 secs
> / 2.002 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 69 of 254 SUCCESS (0 secs
> / 2.007 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 70 of 254 SUCCESS (0 secs
> / 2.012 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 71 of 254 SUCCESS (0 secs
> / 2.017 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 72 of 254 SUCCESS (0 secs
> / 2.022 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 73 of 254 SUCCESS (0 secs
> / 2.027 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 74 of 254 SUCCESS (0 secs
> / 2.033 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 75 of 254 SUCCESS (0 secs
> / 2.037 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 76 of 254 SUCCESS (0 secs
> / 2.042 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 77 of 254 SUCCESS (0 secs
> / 2.078 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 78 of 254 SUCCESS (0 secs
> / 2.082 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 79 of 254 SUCCESS (0 secs
> / 2.116 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 80 of 254 SUCCESS (0 secs
> / 2.142 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 81 of 254 SUCCESS (0 secs
> / 2.166 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 82 of 254 SUCCESS (0 secs
> / 2.195 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 83 of 254 SUCCESS (0 secs
> / 2.219 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 84 of 254 SUCCESS (0 secs
> / 2.248 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 85 of 254 SUCCESS (0 secs
> / 2.27 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 86 of 254 SUCCESS (0 secs
> / 2.29 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 87 of 254 SUCCESS (0 secs
> / 2.311 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 88 of 254 SUCCESS (0 secs
> / 2.331 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 89 of 254 SUCCESS (0 secs
> / 2.351 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 90 of 254 SUCCESS (0 secs
> / 2.37 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 91 of 254 SUCCESS (0 secs
> / 2.414 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 92 of 254 SUCCESS (0 secs
> / 2.435 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 93 of 254 SUCCESS (0 secs
> / 2.456 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 94 of 254 SUCCESS (0 secs
> / 2.476 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 95 of 254 SUCCESS (0 secs
> / 2.492 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 96 of 254 SUCCESS (0 secs
> / 2.508 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 97 of 254 SUCCESS (0 secs
> / 2.531 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 98 of 254 SUCCESS (0 secs
> / 2.546 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 99 of 254 SUCCESS (0 secs
> / 2.587 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 100 of 254 SUCCESS (0 secs
> / 2.607 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 101 of 254 SUCCESS (0 secs
> / 2.624 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 102 of 254 SUCCESS (0 secs
> / 2.644 secs)
>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 103 of 254 SUCCESS (0 secs
> / 2.663 secs)
>  [33m26 07 2017 11:58:03.312:WARN [web-server]:  [39m404:
> /base/pgadmin/

Re: Build failed in Jenkins: pgadmin4-master-python26 #386

2017-07-26 Thread Murtuza Zabuawala
Hi Dave,

Please find a patch to fix the JS tests.

FYI, I have removed the labels like 'Shift+CTRL+/' from test instead used '
inlineComment' because key shortcuts are different based on platform.

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Jul 26, 2017 at 5:32 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Looking into it.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Jul 26, 2017 at 5:28 PM, pgAdmin 4 Jenkins 
> wrote:
>
>> See <https://jenkins.pgadmin.org/job/pgadmin4-master-python26/38
>> 6/display/redirect?page=changes>
>>
>> Changes:
>>
>> [Dave Page] Update keyboard shortcuts per discussion. Also, make the
>> labels platform
>>
>> --
>> [...truncated 357.97 KB...]
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 59 of 254 SUCCESS (0 secs
>> / 1.953 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 60 of 254 SUCCESS (0 secs
>> / 1.958 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 61 of 254 SUCCESS (0 secs
>> / 1.964 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 62 of 254 SUCCESS (0 secs
>> / 1.969 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 63 of 254 SUCCESS (0 secs
>> / 1.974 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 64 of 254 SUCCESS (0 secs
>> / 1.979 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 65 of 254 SUCCESS (0 secs
>> / 1.988 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 66 of 254 SUCCESS (0 secs
>> / 1.993 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 67 of 254 SUCCESS (0 secs
>> / 1.997 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 68 of 254 SUCCESS (0 secs
>> / 2.002 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 69 of 254 SUCCESS (0 secs
>> / 2.007 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 70 of 254 SUCCESS (0 secs
>> / 2.012 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 71 of 254 SUCCESS (0 secs
>> / 2.017 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 72 of 254 SUCCESS (0 secs
>> / 2.022 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 73 of 254 SUCCESS (0 secs
>> / 2.027 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 74 of 254 SUCCESS (0 secs
>> / 2.033 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 75 of 254 SUCCESS (0 secs
>> / 2.037 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 76 of 254 SUCCESS (0 secs
>> / 2.042 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 77 of 254 SUCCESS (0 secs
>> / 2.078 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 78 of 254 SUCCESS (0 secs
>> / 2.082 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 79 of 254 SUCCESS (0 secs
>> / 2.116 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 80 of 254 SUCCESS (0 secs
>> / 2.142 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 81 of 254 SUCCESS (0 secs
>> / 2.166 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 82 of 254 SUCCESS (0 secs
>> / 2.195 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 83 of 254 SUCCESS (0 secs
>> / 2.219 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 84 of 254 SUCCESS (0 secs
>> / 2.248 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 85 of 254 SUCCESS (0 secs
>> / 2.27 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 86 of 254 SUCCESS (0 secs
>> / 2.29 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 87 of 254 SUCCESS (0 secs
>> / 2.311 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 88 of 254 SUCCESS (0 secs
>> / 2.331 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 89 of 254 SUCCESS (0 secs
>> / 2.351 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 90 of 254 SUCCESS (0 secs
>> / 2.37 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 91 of 254 SUCCESS (0 secs
>> / 2.414 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 92 of 254 SUCCESS (0 secs
>> / 2.435 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 93 of 254 SUCCESS (0 secs
>> / 2.456 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 94 of 254 SUCCESS (0 secs
>> / 2.476 secs)
>>  [1A [2KPhantomJS 2.1.1 (Linux 0.0.0): Executed 95 of 254 SUCCESS (0 secs
>> / 2.492 secs)
>>  [1A [2KPhantomJS 2.1.1 (Li

Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-28 Thread Murtuza Zabuawala
Hi Dave,

PFA patch to display additional information from pg_stat_activity table
using subnode control.
RM#2597

Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Tue, Jul 25, 2017 at 10:56 AM, Shirley Wang  wrote:

>
>> On Mon, Jul 24, 2017 at 8:11 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Mon, Jul 24, 2017 at 3:28 PM, Shirley Wang  wrote:
>>>
>>>> 2-3 days is a lot of valuable engineering time. Is this a 'drop
>>>> everything now' kind of feature or can this wait for some user validation
>>>> on a mock up first?
>>>>
>>>
>>> Most of the time will likely be on the infrastructure to change the
>>> display to a subnode control. If you have some cycles to mockup potential
>>> layouts for the subnode view and have them validated, please feel free,
>>> however, that seems like an awful lot of work to me to display some missing
>>> SQL using a standard control.
>>>
>> Regarding SQL display: Developing simple control to show codemirror in
>> disabled state (for now) wont take that much time.
>>
>>
> Part of a product designer's job is to make sure there is a definitive
> need for a feature and that the interface for the feature is designed in
> such a way that the user gets all intended value from it. Time spent
> validating now will decrease the time spent later on redesigning /
> reimplementing.
>
> If everyone is aware of what that value is and confident that how it'll be
> displayed is right, there's little risk in starting to develop it. If we're
> wrong, it'll add to feature bloat and detract from the experience.
>
> Would Chethana be able to take on some of the design work? It would be
> valuable for the dev team to also be part of design process.
>


Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-28 Thread Murtuza Zabuawala
++ Attaching the patch

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jul 28, 2017 at 4:02 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Dave,
>
> PFA patch to display additional information from pg_stat_activity table
> using subnode control.
> RM#2597
>
> Please review.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Tue, Jul 25, 2017 at 10:56 AM, Shirley Wang  wrote:
>
>>
>>> On Mon, Jul 24, 2017 at 8:11 PM, Dave Page  wrote:
>>>
>>>>
>>>>
>>>> On Mon, Jul 24, 2017 at 3:28 PM, Shirley Wang  wrote:
>>>>
>>>>> 2-3 days is a lot of valuable engineering time. Is this a 'drop
>>>>> everything now' kind of feature or can this wait for some user validation
>>>>> on a mock up first?
>>>>>
>>>>
>>>> Most of the time will likely be on the infrastructure to change the
>>>> display to a subnode control. If you have some cycles to mockup potential
>>>> layouts for the subnode view and have them validated, please feel free,
>>>> however, that seems like an awful lot of work to me to display some missing
>>>> SQL using a standard control.
>>>>
>>> Regarding SQL display: Developing simple control to show codemirror in
>>> disabled state (for now) wont take that much time.
>>>
>>>
>> Part of a product designer's job is to make sure there is a definitive
>> need for a feature and that the interface for the feature is designed in
>> such a way that the user gets all intended value from it. Time spent
>> validating now will decrease the time spent later on redesigning /
>> reimplementing.
>>
>> If everyone is aware of what that value is and confident that how it'll
>> be displayed is right, there's little risk in starting to develop it. If
>> we're wrong, it'll add to feature bloat and detract from the experience.
>>
>> Would Chethana be able to take on some of the design work? It would be
>> valuable for the dev team to also be part of design process.
>>
>
>
diff --git a/web/pgadmin/dashboard/static/css/dashboard.css 
b/web/pgadmin/dashboard/static/css/dashboard.css
index 735aebf..074549e 100644
--- a/web/pgadmin/dashboard/static/css/dashboard.css
+++ b/web/pgadmin/dashboard/static/css/dashboard.css
@@ -88,3 +88,20 @@
 margin-top: 13px;
 display: block;
 }
+
+.dashboard-tab-container .form-control {
+font-size: inherit;
+}
+
+#server_activity .CodeMirror,
+#database_activity .CodeMirror,
+#server_activity .CodeMirror-scroll,
+#database_activity .CodeMirror-scroll {
+height: auto;
+max-height:100px;
+}
+
+.dashboard-tab-container .sub-node-form > ul.tab-content {
+  padding-left: 0px;
+  left: 0px;
+}
diff --git a/web/pgadmin/dashboard/static/js/dashboard.js 
b/web/pgadmin/dashboard/static/js/dashboard.js
index 1eee1da..e37e321 100644
--- a/web/pgadmin/dashboard/static/js/dashboard.js
+++ b/web/pgadmin/dashboard/static/js/dashboard.js
@@ -90,6 +90,51 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, 
Backgrid, Flotr,
 }
   });
 
+  // Subnode Cell, which will display subnode control
+  var SessionDetailsCell = Backgrid.Extension.ObjectCell.extend({
+render: function(){
+this.$el.empty();
+this.$el.html("");
+this.$el.html(
+  ""
+);
+this.delegateEvents();
+if (this.grabFocus)
+  this.$el.focus();
+return this;
+}
+  });
+
+  // Subnode Model
+  var ActiveQueryDetailsModel = Backbone.Model.extend({
+defaults: {
+  version: null /* Postgres version */
+},
+schema: [{
+  id: 'backend_type', label: gettext('Backend type'),
+  type: 'text', editable: true, disabled: true,
+  group: gettext('Details'),
+  visible: function(m) {
+return m.get('version') >= 10;
+  }
+},{
+  id: 'query_start', label: gettext('Query started at'),
+  type: 'text', editable: false, disabled: true,
+  group: gettext('Details')
+},{
+  id: 'state_change', label: gettext('Last state changed at'),
+  type: 'text', editable: true, disabled: true,
+  group: gettext('Details')
+},{
+  id: 'query', label: gettext('SQL'),
+  type: 'text', editable: true, disabled: true,
+  control: Backform.SqlFieldControl,
+  group: gettext('Details')
+}]
+  });
+
   pgAdm

Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-07-28 Thread Murtuza Zabuawala
Hi Dave,

On Fri, Jul 28, 2017 at 4:11 PM, Dave Page  wrote:

> Hi
>
> I took a quick look at this and have a couple of thoughts:
>
> - Instead of the "edit" icon to open the subnode, we should use something
> more appropriate - a "properties" icon perhaps.
>
> I used default subnode's edit icon for consistency purpose.
What if we go with caret-right <http://fontawesome.io/icon/caret-right/>
and caret-down <http://fontawesome.io/icon/caret-down/> icons?

> - There seems to be a lot of different shades of grey on there (maybe a
> subnode design in general that just shows up with the disabled controls),
> and the subnode control looks a bit messy as a result.
>
> Can you work with Chethana to improve the look and feel please?
>
> Do you mean only colours or subnode control design itself?

> Input from others welcome of course - screenshot attached.
>
> Thanks.
>
> On Fri, Jul 28, 2017 at 11:33 AM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> ++ Attaching the patch
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Fri, Jul 28, 2017 at 4:02 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> PFA patch to display additional information from pg_stat_activity table
>>> using subnode control.
>>> RM#2597
>>>
>>> Please review.
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Tue, Jul 25, 2017 at 10:56 AM, Shirley Wang  wrote:
>>>
>>>>
>>>>> On Mon, Jul 24, 2017 at 8:11 PM, Dave Page  wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jul 24, 2017 at 3:28 PM, Shirley Wang 
>>>>>> wrote:
>>>>>>
>>>>>>> 2-3 days is a lot of valuable engineering time. Is this a 'drop
>>>>>>> everything now' kind of feature or can this wait for some user 
>>>>>>> validation
>>>>>>> on a mock up first?
>>>>>>>
>>>>>>
>>>>>> Most of the time will likely be on the infrastructure to change the
>>>>>> display to a subnode control. If you have some cycles to mockup potential
>>>>>> layouts for the subnode view and have them validated, please feel free,
>>>>>> however, that seems like an awful lot of work to me to display some 
>>>>>> missing
>>>>>> SQL using a standard control.
>>>>>>
>>>>> Regarding SQL display: Developing simple control to show codemirror in
>>>>> disabled state (for now) wont take that much time.
>>>>>
>>>>>
>>>> Part of a product designer's job is to make sure there is a definitive
>>>> need for a feature and that the interface for the feature is designed in
>>>> such a way that the user gets all intended value from it. Time spent
>>>> validating now will decrease the time spent later on redesigning /
>>>> reimplementing.
>>>>
>>>> If everyone is aware of what that value is and confident that how it'll
>>>> be displayed is right, there's little risk in starting to develop it. If
>>>> we're wrong, it'll add to feature bloat and detract from the experience.
>>>>
>>>> Would Chethana be able to take on some of the design work? It would be
>>>> valuable for the dev team to also be part of design process.
>>>>
>>>
>>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: Error using pgadmin4 HEAD

2017-07-28 Thread Murtuza Zabuawala
Hi,

With pgAdmin4 version 1.6, we have changed the way we bundle and serve the
javascript and other static files. Refer steps in this email thread
<https://www.postgresql.org/message-id/cakkotzst2nnzavaf4vd5fo-nm_dcq4qen4fcgydx-xabfe7...@mail.gmail.com>,
if you want to use it from git repository, Another way is to download and
use the source which is already bundled from here
<https://www.pgadmin.org/download/pgadmin-4-source-code/>

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Sat, Jul 29, 2017 at 2:27 AM, Dave Cramer  wrote:

> OK,
>
> I am running macos 10.12.6
> compiled from source using QT5.5clang
> using current HEAD version
> followed the instructions config_local has SERVER_MODE = False
> python setup.py does not error
>
> from the runtime dir executed 'open pgadmin4.app'
>
> The error message is the same "The application server could not be
> contacted"
>
> Thanks,
>
> Dave Cramer
>
> On 28 July 2017 at 07:49, Dave Cramer  wrote:
>
>> Hi Kushboo,
>>
>> Thanks for the quick reply. I compiled it from HEAD. I will follow the
>> instructions for deployment and get back to you .
>>
>> Dave
>>
>> Dave Cramer
>>
>> On 27 July 2017 at 21:59, Khushboo Vashi > > wrote:
>>
>>> 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
>>> <https://www.pgadmin.org/docs/pgadmin4/1.x/deployment.html> 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
>>>>
>>>
>>>
>>
>


[pgAdmin4][Patch]: Fix the Domain Create dialog issue

2017-07-31 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix two issues,

1) Domain's Create/Properties dialog do not open due to JS error.
- Global variable issue.

2) Security label control's label font size issue.
- Backgrid adds backbone model id(which is 'label' in our case) in as a
class in  tag causing font size class collision with Bootstrap's label
class.

RM#2616


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
index af24900..b3b092a 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
@@ -123,7 +123,7 @@ define('pgadmin.node.domain', [
   var isNew = (_.size(attrs) === 0);
   if (isNew) {
 // Set Selected Schema
-schema = args.node_info.schema.label
+var schema = args.node_info.schema.label
 this.set({'basensp': schema}, {silent: true});
 
 // Set Current User
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js 
b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index ab753f6..3dfdfb0 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -23,6 +23,7 @@ define('pgadmin.node.server', [
   },{
 id: 'label', label: gettext('Security Label'),
 type: 'text', editable: true,
+cellHeaderClasses:'override_label_class_font_size'
   }],
   validate: function() {
 var err = {},
diff --git a/web/pgadmin/static/css/bootstrap.overrides.css 
b/web/pgadmin/static/css/bootstrap.overrides.css
index 6274c74..f4d21b3 100755
--- a/web/pgadmin/static/css/bootstrap.overrides.css
+++ b/web/pgadmin/static/css/bootstrap.overrides.css
@@ -1335,3 +1335,8 @@ body {
   font-size: 14px;
   font-weight: normal;
 }
+
+/* Security label's label column font size */
+.override_label_class_font_size {
+  font-size: inherit !important;
+}


Re: pgAdmin 4 commit: Fix test assertion.

2017-07-31 Thread Murtuza Zabuawala
Hi All,

When I run the feature tests, the gives test always fails (
'query_tool_journey_test.py'),

Python: 3.6 (64-bit)
Platform: OS X (10.10.5)

Am I the only one who gets this error?


==
ERROR: runTest
(pgadmin.feature_tests.query_tool_journey_test.QueryToolJourneyTest)
Tests the path through the query tool
--
Traceback (most recent call last):
  File
"/Users/edb/Documents/projects/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
line 46, in runTest
self._test_history_tab()
  File
"/Users/edb/Documents/projects/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
line 104, in _test_history_tab
query_we_need_to_scroll_to
  File
"/Users/edb/Documents/projects/pgadmin4/web/pgadmin/feature_tests/query_tool_journey_test.py",
line 141, in _assert_not_clickable_because_out_of_view
self.assertRaises(self.page.click_element(element))
  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py",
line 728, in assertRaises
return context.handle('assertRaises', args, kwargs)
  File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py",
line 158, in handle
(name, self._base_type_str))
TypeError: assertRaises() arg 1 must be an exception type or tuple of
exception types

--
Ran 10 tests in 359.301s

FAILED (errors=1, skipped=1)

==
Test Result Summary
==

PG_95:

8 tests passed
1 test failed:
QueryToolJourneyTest (Tests the path through the query tool)
1 test skipped:
CheckDebuggerForXssFeatureTest (Tests to check if Debugger is vulnerable to
XSS)


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jul 21, 2017 at 8:46 PM, Dave Page  wrote:

> Fix test assertion.
>
> Branch
> --
> master
>
> Details
> ---
> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=
> 2ebb40819534d79376a577a149a8a5db124b
> Author: Sarah McAlear 
>
> Modified Files
> --
> web/pgadmin/feature_tests/query_tool_journey_test.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>


Re: Discussion on improving alertify notifications logic

2017-07-31 Thread Murtuza Zabuawala
Hi,

Looks good to me.

Regards,
Murtuza
On Mon, Jul 31, 2017 at 2:59 PM, Ashesh Vashi  wrote:

> On Mon, Jul 31, 2017 at 2:54 PM, Akshay Joshi <
> akshay.jo...@enterprisedb.com> wrote:
>
>> Hi All
>>
>
>> On Fri, Jul 28, 2017 at 1:51 PM, Dave Page  wrote:
>>
>>>
>>>
>>> On Thu, Jul 27, 2017 at 2:41 PM, Akshay Joshi <
>>> akshay.jo...@enterprisedb.com> wrote:
>>>
 Hi All

 As in commit "Update alertify alerts to use the styling defined in
 the style guide":

 https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=commitdiff
 ;h=2a30a86e7d5e562040500f448fbb0d143ff2cff9

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

 We have introduce new wrapper class "AlertifyWrapper" and replace
 calls to alertify.success and alertify.error with following two lines
 in most of the files

 var alertifyWrapper = new AlertifyWrapper();

 alertifyWrapper.success(message);  or  alertifyWrapper.error(message);

 For each call we are creating dynamic object of AlertifyWrapper and
 call the appropriate function. For example there are 20 such calls in a
 single js file every time are are creating object and call appropriate
 function.

 I have tried to improve the logic here and implemented it as below:

- Extend alertify and move success, error and info functions from "
alertify_wrapper.js" file to "alertify.pgadmin.defaults.js", there
will be no use of "alertify_wrapper.js"
- Modify only "server.js" as POC, remove 'alertify' and replace
'sources/alerts/alertify_wrapper' with 'pgadmin.alertifyjs' which
is nothing but mapping of "alertify.pgadmin.defaults.js" from
defines and named the reference object to 'alertify' so no need to 
 change
any function call like "alertify.success, alertify.error".

 One more benefit of the above approach is if in future we want to use
 the same style for alertify.warning, alertify.info, alertify.message
 etc.., we will just have to extend that method in "alertify.pgadmin
 .defaults.js" and no need to change the rest of the function call with
 AlertifyWrapper.

 Attached is the POC patch, if it looks good then I'll start working on
 replacing AlertifyWrapper with the above mentioned approach.

>>>
>>> I like the approach - it's definitely cleaner, and saves instantiating a
>>> new object every time.
>>>
>>
>>I have modified the logic to improve the usage of alrtify
>> notification. Attached is the patch file which contains following:
>>
>>- Replace 'alertify' with 'pgadmin.alertifyjs' in define[].
>>- Remove 'sources/alerts/alertify_wrapper' from define[].
>>- Replace calls var alertifyWrapper = new AlertifyWrapper();
>>alertifyWrapper.success(message);  or  alertifyWrapper*.error(message);
>>*with appropriate (alertify.success/alertify.error..)
>>- Modified test case written for alertify wrapper.
>>
>>
>>   Please review it and if it looks good then I'll commit the code.
>>
> Murtuza,
>
> Please review it.
>
> -- Thanks, Ashesh
>
>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>>
>> --
>> *Akshay Joshi*
>> *Principal Software Engineer *
>>
>>
>>
>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>
>
>


Re: pgAdmin 4 commit: Fix test assertion.

2017-07-31 Thread Murtuza Zabuawala
Hi Robert,

I have the latest pull and still this test is fails every time on my
machine, not sure if it is because of Python3.6.

On Mon, Jul 31, 2017 at 5:27 PM, Robert Eckhardt 
wrote:

> This was broken when the clear button and the edit button were changed to
> drop downs.  Happened a few weeks ago.
>
> Rob
>
> On Jul 31, 2017 6:51 PM, "Murtuza Zabuawala"  enterprisedb.com> wrote:
>
> Hi All,
>
> When I run the feature tests, the gives test always fails (
> 'query_tool_journey_test.py'),
>
> Python: 3.6 (64-bit)
> Platform: OS X (10.10.5)
>
> Am I the only one who gets this error?
>
>
> ==
> ERROR: runTest (pgadmin.feature_tests.query_t
> ool_journey_test.QueryToolJourneyTest)
> Tests the path through the query tool
> --
> Traceback (most recent call last):
>   File "/Users/edb/Documents/projects/pgadmin4/web/pgadmin/feature_
> tests/query_tool_journey_test.py", line 46, in runTest
> self._test_history_tab()
>   File "/Users/edb/Documents/projects/pgadmin4/web/pgadmin/feature_
> tests/query_tool_journey_test.py", line 104, in _test_history_tab
> query_we_need_to_scroll_to
>   File "/Users/edb/Documents/projects/pgadmin4/web/pgadmin/feature_
> tests/query_tool_journey_test.py", line 141, in
> _assert_not_clickable_because_out_of_view
> self.assertRaises(self.page.click_element(element))
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py",
> line 728, in assertRaises
> return context.handle('assertRaises', args, kwargs)
>   File 
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py",
> line 158, in handle
> (name, self._base_type_str))
> TypeError: assertRaises() arg 1 must be an exception type or tuple of
> exception types
>
> --
> Ran 10 tests in 359.301s
>
> FAILED (errors=1, skipped=1)
>
> ==
> Test Result Summary
> ==
>
> PG_95:
>
> 8 tests passed
> 1 test failed:
> QueryToolJourneyTest (Tests the path through the query tool)
> 1 test skipped:
> CheckDebuggerForXssFeatureTest (Tests to check if Debugger is vulnerable
> to XSS)
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Jul 21, 2017 at 8:46 PM, Dave Page  wrote:
>
>> Fix test assertion.
>>
>> Branch
>> --
>> master
>>
>> Details
>> ---
>> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdif
>> f;h=2ebb40819534d79376a577a149a8a5db124b
>> Author: Sarah McAlear 
>>
>> Modified Files
>> --
>> web/pgadmin/feature_tests/query_tool_journey_test.py | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>
>
>


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

2017-07-31 Thread Murtuza Zabuawala
Hi Ashesh,
On Mon, Jul 31, 2017 at 4:50 PM, Ashesh Vashi  wrote:

>
>
> On Fri, Jul 28, 2017 at 4:00 PM, Dave Page  wrote:
>
>> Ashesh, can you deal with this please? Thanks.
>>
> Hi Khushboo,
>
> I've committed the code.
> But - I am not able to reopen the dashboard panel once it is closed, even
> not from the docker context menu -> Add Panel > Dashboard.
>
> I have asked Murtuza to look into it.
>
I am able to open Dashboard panel with given steps, I also observed that
I'm allowed to open more than one Dashboard panels with same steps.

>
>
--
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
>>
>> On Thu, Jul 27, 2017 at 6:20 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> 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
>>>
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


[pgAdmin4][Patch]: To fix Collation tests

2017-08-01 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the Collation tests on Windows, Instead of default "POSIX"
collation, we have now used default "C" collation for testing, I have
tested it macOS, Linux & Windows platform the tests are working fine.
RM#2501

I have also reported bug in Postgres community regarding "POSIX" collation
issue on Windows.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/test_collation_add.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/test_collation_add.py
index ee283aa..84b81e7 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/test_collation_add.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/test_collation_add.py
@@ -58,7 +58,7 @@ class CollationAddTestCase(BaseTestGenerator):
 raise Exception("Could not find the schema to add the collation.")
 
 data = {
-"copy_collation": "pg_catalog.\"POSIX\"",
+"copy_collation": "pg_catalog.\"C\"",
 "name": "collation_add_%s" % str(uuid.uuid4())[1:6],
 "owner": self.server["username"],
 "schema": schema_name
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/utils.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/utils.py
index 7a55785..c24eb79 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/utils.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/tests/utils.py
@@ -25,7 +25,7 @@ def create_collation(server, schema_name, coll_name, db_name):
  server['port'],
  server['sslmode'])
 pg_cursor = connection.cursor()
-pg_cursor.execute('CREATE COLLATION %s.%s FROM pg_catalog."POSIX"' %
+pg_cursor.execute('CREATE COLLATION %s.%s FROM pg_catalog."C"' %
   (schema_name, coll_name))
 connection.commit()
 


[pgAdmin4][Patch]: To fix Function/Procedures messages issue in query tool

2017-08-02 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where in query tool, messages were not
displaying from functions/procedures properly.
RM#2555

Needs to be reviewed with (Success/Fail/Error scenarios):
1) Table output
2) Function output
3) Procedure output (EPAS)
4) Adhoc query output (like vacuum)

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/sqleditor/__init__.py 
b/web/pgadmin/tools/sqleditor/__init__.py
index 2ffc74a..15ec8c4 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -528,7 +528,6 @@ def poll(trans_id):
 rows_fetched_from = 0
 rows_fetched_to = 0
 has_more_rows = False
-additional_result = []
 columns = dict()
 columns_info = None
 primary_keys = None
@@ -640,30 +639,23 @@ def poll(trans_id):
 status = 'NotConnected'
 result = error_msg
 
-# Procedure/Function output may comes in the form of Notices from the
-# database server, so we need to append those outputs with the
-# original result.
-
-if status == 'Success' and result is None:
-result = conn.status_message()
-messages = conn.messages()
-if messages:
-additional_result = ''.join(messages)
-else:
-additional_result = ''
-if result != 'SELECT 1' and result is not None:
-result = additional_result + result
-else:
-result = additional_result
-
 # There may be additional messages even if result is present
 # eg: Function can provide result as well as RAISE messages
 additional_messages = None
-if status == 'Success' and result is not None:
+if status == 'Success':
 messages = conn.messages()
 if messages:
 additional_messages = ''.join(messages)
 
+# Procedure/Function output may comes in the form of Notices from the
+# database server, so we need to append those outputs with the
+# original result.
+if status == 'Success' and result is None:
+result = conn.status_message()
+if (result != 'SELECT 1' or result != 'SELECT 0') \
+and result is not None and additional_messages:
+result = additional_messages + result
+
 return make_json_response(
 data={
 'status': status, 'result': result,
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js 
b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 6452744..3e61f10 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -1889,14 +1889,13 @@ define('tools.querytool', [
 
   var _msg = msg1 + '\n' + msg2;
 
-  self.update_msg_history(true, _msg, false);
   // If there is additional messages from server then add it to 
message
   if(!_.isNull(data.additional_messages) &&
 !_.isUndefined(data.additional_messages)) {
 _msg = data.additional_messages + '\n' + _msg;
   }
 
-  $('.sql-editor-message').text(_msg);
+  self.update_msg_history(true, _msg, false);
 
   /* Add the data to the collection and render the grid.
* In case of Explain draw the graph on explain panel
@@ -2080,7 +2079,7 @@ define('tools.querytool', [
 
 $('.sql-editor-message').text(msg);
   } else {
-$('.sql-editor-message').append(msg);
+$('.sql-editor-message').append(_.escape(msg));
   }
 
   // Scroll automatically when msgs appends to element


[pgAdmin4][Patch]: Use the correct resultset type for Type module

2017-08-03 Thread Murtuza Zabuawala
Hi,

PFA minor patch to use fetch dict based data instead of 2d-array based in
Type module as we are adding keys on the fly.
There is no RM just a minor enhancement.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
index 07df594..085ab43 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
@@ -403,7 +403,7 @@ class TypeView(PGChildNodeView, DataTypeReader):
 'additional_properties.sql']),
   type='c',
   typrelid=copy_dict['typrelid'])
-status, rset = self.conn.execute_2darray(SQL)
+status, rset = self.conn.execute_dict(SQL)
 if not status:
 return internal_server_error(errormsg=res)
 


Re: [pgAdmin4][PATCH] Refactor and change of implementation of keyboard_shortcuts function dependencies

2017-08-04 Thread Murtuza Zabuawala
Hi Sarah,

Could you please rebase and send the patch again, I am not able to apply
any of the patch.

murtuza@laptop:~/Documents/projects/pgadmin4$ git apply
~/Downloads/1_refactor_keyactions.diff
error: patch failed: web/pgadmin/tools/sqleditor/static/js/sqleditor.js:552
error: web/pgadmin/tools/sqleditor/static/js/sqleditor.js: patch does not
apply
murtuza@laptop:~/Documents/projects/pgadmin4$ git apply
~/Downloads/2_change_keyboard_shortcuts_for_commenting.diff
error: patch failed:
web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js:26
error: web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js: patch does
not apply
error: patch failed:
web/regression/javascript/sqleditor/keyboard_shortcuts_spec.js:181
error: web/regression/javascript/sqleditor/keyboard_shortcuts_spec.js:
patch does not apply


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Fri, Aug 4, 2017 at 5:37 PM, Ashesh Vashi 
wrote:

> Murtuza,
>
> On Thu, Aug 3, 2017 at 3:38 PM, Sarah McAlear  wrote:
>
>> Hi Hackers!
>>
>> Attached is a patch that extracts the functions called by the
>> keyboard_shortcuts function extracted earlier from sqlEditor. This
>> includes
>>
>>- executeQuery
>>- explainAnalyze
>>- explain
>>- download
>>- commentBlockCode
>>- commentLineCode
>>- uncommentLineCode
>>
>>
>> There is still more work to be done, but this is it for now.
>>
>> There is also an additional patch that changes the implementation of the
>> commentLineCode, uncommentLineCode, and commentBlockCode functions. The
>> shortcut
>>
>>- for commentLineCode is now  cmd + / (ctrl + / for Windows)
>>- for uncommentLineCode cmd + . (ctrl + . for Windows)
>>- for comment and uncomment blockCode shift + cmd + / (shift + ctrl +
>>/ for Windows)
>>
>> This is consistent with other IDEs and the way commenting is implemented.
>>
> Please review it, and let us know your comments.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
>>
>> Thanks!
>> Hao & Sarah
>>
>
>


[pgAdmin4][PATCH] To fix the add New Server through Quick links on Dashboard

2017-08-07 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where add new server functionality through
Quick link on Dashboard is broken.
RM#2634

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>
diff --git a/web/pgadmin/dashboard/static/js/dashboard.js 
b/web/pgadmin/dashboard/static/js/dashboard.js
index 86ebe38..22b7675 100644
--- a/web/pgadmin/dashboard/static/js/dashboard.js
+++ b/web/pgadmin/dashboard/static/js/dashboard.js
@@ -357,11 +357,13 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, 
Backgrid, Flotr,
 // Handler function to support the "Add Server" link
 add_new_server: function() {
 if (pgBrowser && pgBrowser.tree) {
-var i = pgBrowser.tree.first(null, false),
-serverModule = r('pgadmin.node.server'),
-itemData = pgBrowser.tree.itemData(i);
+var i = pgBrowser.tree.selected().length != 0 ?
+  pgBrowser.tree.selected() :
+  pgBrowser.tree.first(null, false),
+ serverModule = r('pgadmin.node.server'),
+ itemData = pgBrowser.tree.itemData(i);
 
-while (itemData && itemData._type != "server-group") {
+while (itemData && itemData._type != "server_group") {
 i = pgBrowser.tree.next(i);
 itemData = pgBrowser.tree.itemData(i);
 }


Re: Can someone tell me what this code does ?

2017-08-07 Thread Murtuza Zabuawala
Hi,

This piece of code allow us to dynamically import all the available driver
modules from '../utils/driver/' directory into our application.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 4:20 AM, Dave Cramer  wrote:

> I'm fairly new to Python so excuse my naiveté.
>
> This code: in web/pgadmin/utils/driver/__init__.py  does not appear to
> load the drivers into the drivers dictionary ? Or am I missing something
>
> def init_app(app):
> drivers = dict()
>
> setattr(app, '_pgadmin_server_drivers', drivers)
> DriverRegistry.load_drivers()
>
> return drivers
>
>
>
> Dave Cramer
>


Re: [pgAdmin4][Patch][RM_2567] : Default privileges don't show on Properties tab for database.

2017-08-08 Thread Murtuza Zabuawala
Hi Atul,

The given patch breaks RM#1801 <https://redmine.postgresql.org/issues/1801>.
After applying the patch, Now I'm not able to see the properties of a
database of which "datallowconn" is set to False.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 12:08 PM, Ashesh Vashi  wrote:

> Murtuza,
>
> Please review this one.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
> On Tue, Aug 1, 2017 at 3:23 PM, Atul Sharma 
> wrote:
>
>> Hi,
>>
>> PFA patch that fixes Default privileges don't show on Properties tab for
>> database
>>
>> Thanks,
>> Atul
>>
>
>


Re: [pgAdmin4][PATCH] To fix the add New Server through Quick links on Dashboard

2017-08-08 Thread Murtuza Zabuawala
Hi,

PFA updated patch for the same.

Thanks Surinder for pointing that out, I assumed that we had a typo in that
file.



--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 12:18 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi Murtuza,
>
> As type server-group is renamed to server_group, I can see there are
> other occurrences of string server-group which needs to be replaced when
> I perform search in pgAdmin4.
>
> Can you please take care of those occurrences?
>
> Thanks,
> Surinder
>
> On Tue, Aug 8, 2017 at 12:02 PM, Murtuza Zabuawala [murtuza.zabuawala@
> enterprisedb.com](mailto:murtuza.zabuaw...@enterprisedb.com)
> <http://mailto:%5bmurtuza.zabuaw...@enterprisedb.com%5D(mailto:murtuza.zabuaw...@enterprisedb.com)>
> wrote:
>
> Hi,
>>
>> PFA minor patch to fix the issue where add new server functionality
>> through Quick link on Dashboard is broken.
>> RM#2634
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> [image: https://community.postgresrocks.net/]
>> <https://community.postgresrocks.net/>
>>
> ​
>
diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js 
b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
index 44703f1..d7f3f40 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
+++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
@@ -556,8 +556,7 @@ define('pgadmin.node.role', [
   return null;
 }
   })
-}),
-sg = pgBrowser.Nodes['server-group'];
+})
   }
 
   return pgBrowser.Nodes['role'];
diff --git a/web/pgadmin/browser/templates/browser/js/utils.js 
b/web/pgadmin/browser/templates/browser/js/utils.js
index 2e59512..a3723ec 100644
--- a/web/pgadmin/browser/templates/browser/js/utils.js
+++ b/web/pgadmin/browser/templates/browser/js/utils.js
@@ -9,7 +9,7 @@ define('pgadmin.browser.utils',
 
   // Define list of nodes on which Query tool option doesn't appears
   var unsupported_nodes = pgAdmin.unsupported_nodes = [
- 'server-group', 'server', 'coll-tablespace', 'tablespace',
+ 'server_group', 'server', 'coll-tablespace', 'tablespace',
  'coll-role', 'role', 'coll-resource_group', 'resource_group',
  'coll-database'
   ];
@@ -85,4 +85,4 @@ define('pgadmin.browser.utils',
 }
   };
   return pgBrowser;
-});
\ No newline at end of file
+});
diff --git a/web/pgadmin/dashboard/static/js/dashboard.js 
b/web/pgadmin/dashboard/static/js/dashboard.js
index 86ebe38..22b7675 100644
--- a/web/pgadmin/dashboard/static/js/dashboard.js
+++ b/web/pgadmin/dashboard/static/js/dashboard.js
@@ -357,11 +357,13 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, 
Backgrid, Flotr,
 // Handler function to support the "Add Server" link
 add_new_server: function() {
 if (pgBrowser && pgBrowser.tree) {
-var i = pgBrowser.tree.first(null, false),
-serverModule = r('pgadmin.node.server'),
-itemData = pgBrowser.tree.itemData(i);
+var i = pgBrowser.tree.selected().length != 0 ?
+  pgBrowser.tree.selected() :
+  pgBrowser.tree.first(null, false),
+ serverModule = r('pgadmin.node.server'),
+ itemData = pgBrowser.tree.itemData(i);
 
-while (itemData && itemData._type != "server-group") {
+while (itemData && itemData._type != "server_group") {
 i = pgBrowser.tree.next(i);
 itemData = pgBrowser.tree.itemData(i);
 }
diff --git a/web/pgadmin/static/js/check_node_visibility.js 
b/web/pgadmin/static/js/check_node_visibility.js
index 18b6655..5a627ec 100644
--- a/web/pgadmin/static/js/check_node_visibility.js
+++ b/web/pgadmin/static/js/check_node_visibility.js
@@ -24,7 +24,7 @@ define(['jquery', 'underscore', 'underscore.string'],
 
   // Exclude non-applicable nodes
   var nodes_not_supported = [
-"server-group", "server", "catalog_object_column"
+"server_group", "server", "catalog_object_column"
   ];
   if(_.indexOf(nodes_not_supported, node_type) >= 0) {
 return true;


Re: [pgAdmin4][Patch][RM_2567] : Default privileges don't show on Properties tab for database.

2017-08-08 Thread Murtuza Zabuawala
Hi Atul,

Better solution to solve this issue is to use self.conn instead of creating
new conn using did, we already checking for "datallowconn" flag in
check_precondition
decorator.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 12:42 PM, Atul Sharma 
wrote:

> ok, Lemme check and I will get back to you.
>
> Thanks,
> Atul
>
> On Tue, Aug 8, 2017 at 12:40 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Atul,
>>
>> The given patch breaks RM#1801
>> <https://redmine.postgresql.org/issues/1801>.
>> After applying the patch, Now I'm not able to see the properties of a
>> database of which "datallowconn" is set to False.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> [image: https://community.postgresrocks.net/]
>> <https://community.postgresrocks.net/>
>>
>> On Tue, Aug 8, 2017 at 12:08 PM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> Murtuza,
>>>
>>> Please review this one.
>>>
>>> --
>>>
>>> Thanks & Regards,
>>>
>>> Ashesh Vashi
>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>> <http://www.enterprisedb.com>
>>>
>>>
>>> *http://www.linkedin.com/in/asheshvashi*
>>> <http://www.linkedin.com/in/asheshvashi>
>>>
>>> On Tue, Aug 1, 2017 at 3:23 PM, Atul Sharma <
>>> atul.sha...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch that fixes Default privileges don't show on Properties tab
>>>> for database
>>>>
>>>> Thanks,
>>>> Atul
>>>>
>>>
>>>
>>
>


Re: [pgAdmin4][PATCH] Refactor and change of implementation of keyboard_shortcuts function dependencies

2017-08-08 Thread Murtuza Zabuawala
Hi Wenlin,

Patch looks good to me.

I'm also attaching minor patch to update document for new keyboard
shortcuts.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 1:41 PM, Wenlin Zhang  wrote:

> Hi Murtuza,
>
>  Thanks for your review.
>
>   We have fixed download bug, you can try it with the new patch
> 1.3_refactor_keyactions.diff, to see if it works.
>   And we also changed the typo in the patch
> 2.1_change_keyboard_shortcuts_for_commenting_and_fix_typo.diff, 
> ('client_plaform'
> -> 'client_platform').
>
> Thanks.
>
> Wenlin & Violet
>
> On Mon, Aug 7, 2017 at 2:30 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Sarah,
>>
>> - Download button is not working, getting error on console (attaching
>> screenshot).
>> - While testing the patch I also observed another minor issue, If we
>> click on Explain & Explain analyze buttons, previous messages from Message
>> tab are not getting clear but instead new messages are getting appended to
>> previous ones.
>>
>> And could you please correct a typo introduced by Me from file
>> ../templates/datagrid/index.html, 'client_plaform' -> 'client_platform'
>> in your next patch as you working on it :)
>>
>> Rest of the changes looks good to me.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> On Mon, Aug 7, 2017 at 8:09 AM, Sarah McAlear 
>> wrote:
>>
>>> Hi Murtuza,
>>>
>>>  We have rebased and send the new patch.
>>>
>>> Thanks,
>>>
>>> Wenlin and Sarah
>>>
>>> On Fri, Aug 4, 2017 at 8:54 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Sarah,
>>>>
>>>> Could you please rebase and send the patch again, I am not able to
>>>> apply any of the patch.
>>>>
>>>> murtuza@laptop:~/Documents/projects/pgadmin4$ git apply
>>>> ~/Downloads/1_refactor_keyactions.diff
>>>> error: patch failed: web/pgadmin/tools/sqleditor/st
>>>> atic/js/sqleditor.js:552
>>>> error: web/pgadmin/tools/sqleditor/static/js/sqleditor.js: patch does
>>>> not apply
>>>> murtuza@laptop:~/Documents/projects/pgadmin4$ git apply
>>>> ~/Downloads/2_change_keyboard_shortcuts_for_commenting.diff
>>>> error: patch failed: web/pgadmin/static/js/sqledito
>>>> r/keyboard_shortcuts.js:26
>>>> error: web/pgadmin/static/js/sqleditor/keyboard_shortcuts.js: patch
>>>> does not apply
>>>> error: patch failed: web/regression/javascript/sqle
>>>> ditor/keyboard_shortcuts_spec.js:181
>>>> error: web/regression/javascript/sqleditor/keyboard_shortcuts_spec.js:
>>>> patch does not apply
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Murtuza Zabuawala
>>>> EnterpriseDB: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> [image: https://community.postgresrocks.net/]
>>>> <https://community.postgresrocks.net/>
>>>>
>>>> On Fri, Aug 4, 2017 at 5:37 PM, Ashesh Vashi <
>>>> ashesh.va...@enterprisedb.com> wrote:
>>>>
>>>>> Murtuza,
>>>>>
>>>>> On Thu, Aug 3, 2017 at 3:38 PM, Sarah McAlear 
>>>>> wrote:
>>>>>
>>>>>> Hi Hackers!
>>>>>>
>>>>>> Attached is a patch that extracts the functions called by the
>>>>>> keyboard_shortcuts function extracted earlier from sqlEditor. This
>>>>>> includes
>>>>>>
>>>>>>- executeQuery
>>>>>>- explainAnalyze
>>>>>>- explain
>>>>>>- download
>>>>>>- commentBlockCode
>>>>>>- commentLineCode
>>>>>>- uncommentLineCode
>>>>>>
>>>>>>
>>>>>> There is still more work to be done, but this is it for now.
>>>>>>
>>>>>> There is also an additional patch that changes the implementation of
>>>>>> the commentLineCode, uncommentLineCode, and commentBlockCode 

Re: [pgAdmin4][Patch][RM_2567] : Default privileges don't show on Properties tab for database.

2017-08-08 Thread Murtuza Zabuawala
Patch looks good to me.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 3:25 PM, Atul Sharma 
wrote:

> makes sense. Thanks for the solution.
>
> Please find attached revised patch.
>
> Thanks,
> Atul
>
> On Tue, Aug 8, 2017 at 2:12 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi Atul,
>>
>> Better solution to solve this issue is to use self.conn instead of
>> creating new conn using did, we already checking for "datallowconn" flag
>> in check_precondition decorator.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> [image: https://community.postgresrocks.net/]
>> <https://community.postgresrocks.net/>
>>
>> On Tue, Aug 8, 2017 at 12:42 PM, Atul Sharma <
>> atul.sha...@enterprisedb.com> wrote:
>>
>>> ok, Lemme check and I will get back to you.
>>>
>>> Thanks,
>>> Atul
>>>
>>> On Tue, Aug 8, 2017 at 12:40 PM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Atul,
>>>>
>>>> The given patch breaks RM#1801
>>>> <https://redmine.postgresql.org/issues/1801>.
>>>> After applying the patch, Now I'm not able to see the properties of a
>>>> database of which "datallowconn" is set to False.
>>>>
>>>> --
>>>> Regards,
>>>> Murtuza Zabuawala
>>>> EnterpriseDB: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> [image: https://community.postgresrocks.net/]
>>>> <https://community.postgresrocks.net/>
>>>>
>>>> On Tue, Aug 8, 2017 at 12:08 PM, Ashesh Vashi <
>>>> ashesh.va...@enterprisedb.com> wrote:
>>>>
>>>>> Murtuza,
>>>>>
>>>>> Please review this one.
>>>>>
>>>>> --
>>>>>
>>>>> Thanks & Regards,
>>>>>
>>>>> Ashesh Vashi
>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>> <http://www.enterprisedb.com>
>>>>>
>>>>>
>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>> <http://www.linkedin.com/in/asheshvashi>
>>>>>
>>>>> On Tue, Aug 1, 2017 at 3:23 PM, Atul Sharma <
>>>>> atul.sha...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA patch that fixes Default privileges don't show on Properties tab
>>>>>> for database
>>>>>>
>>>>>> Thanks,
>>>>>> Atul
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Can someone tell me what this code does ?

2017-08-09 Thread Murtuza Zabuawala
Yes, you are correct, at a moment that's all it does.

On Tue, Aug 8, 2017 at 6:37 PM, Dave Cramer  wrote:

> Hi,
>
> I guess my question was a bit vague. I get that it loads drivers. But note
> it does not actually put them anywhere.
>
> First it creates a dict
> sets the attribute in the app
> loads the drivers dynamically
> and returns an empty dict.
>
> From what I can tell this:
>
> DriverRegistry.load_drivers()
>
> is all it does?
>
>
>
>
>
>
> Dave Cramer
>
> On 7 August 2017 at 23:35, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> This piece of code allow us to dynamically import all the available
>> driver modules from '../utils/driver/' directory into our application.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> [image: https://community.postgresrocks.net/]
>> <https://community.postgresrocks.net/>
>>
>> On Tue, Aug 8, 2017 at 4:20 AM, Dave Cramer  wrote:
>>
>>> I'm fairly new to Python so excuse my naiveté.
>>>
>>> This code: in web/pgadmin/utils/driver/__init__.py  does not appear to
>>> load the drivers into the drivers dictionary ? Or am I missing something
>>>
>>> def init_app(app):
>>> drivers = dict()
>>>
>>> setattr(app, '_pgadmin_server_drivers', drivers)
>>> DriverRegistry.load_drivers()
>>>
>>> return drivers
>>>
>>>
>>>
>>> Dave Cramer
>>>
>>
>>
>


Re: [pgAdmin4][Patch]: Allow user to cancel long running queries from dashboard

2017-08-09 Thread Murtuza Zabuawala
Hi,

Please find the updated patch with new UI style in dashboard subnode
control based on Chethana's design suggestion.

@Shirley,
Yes, DBA needs to click on the drop down to expand.
- If we make whole row clickable then how are we going to identify if user
is trying to expand the row or trying to cancel the active session? I am
asking this because table row  tag comes before table column tag 
in HTML DOM, so if we have click event listers on both of the tags then how
are we going to differentiate the user operation?
- In my opinion, another reason we can not do that on a dashboard grid
because it will break the subnode control consistency, If user sees that
grid expands on clicking the row they will expect the same behaviour in
other grids as well.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>

On Tue, Aug 8, 2017 at 7:47 PM, Shirley Wang  wrote:

> Nice!
>
> Would a DBA need to click on the drop down to expand? I think that drop
> down icon might be too small. Perhaps the whole row could be a clickable
> area to show further details. This is a good thing to test with some people
>
>
> On Aug 8, 2017, at 12:52, Ashesh Vashi 
> wrote:
>
> On Mon, Aug 7, 2017 at 9:06 PM, Dave Page  wrote:
>
>>
>>
>> On Mon, Aug 7, 2017 at 3:49 PM, Chethana Kumar <
>> chethana.ku...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>>
>>> Could you comment on the new design update for subnode control ?
>>>
>>> Attached designs -
>>>
>>> 1. subnode_current.png -  The existing view
>>> 2. subnode_new.png - The updated view
>>> 3. current_new.png - Existing and new design placed together for
>>> comparison purpose
>>>
>>> Below changes done -
>>>
>>> 1. Reduced number of gray color variations
>>> 2. Made more simplified by removing unwanted borders
>>> 3. Merged "Arrow Down" background and the body background for more
>>> clarity
>>>
>>> Please feel free to provide your input on the same.
>>>
>>
>> Much nicer in my opinion! Good work.
>>
>> Anyone else have any comments?
>>
> It looks much nicer.
> I would like to see the effect on another dialogs like 'Table properties',
> where we have multiple level of subgrid controls with tabs.
>
> -- Thanks, Ashesh
>
>>
>>
>>>
>>> Regards,
>>> Chethana kumar
>>>
>>>
>>>
>>> On Fri, Jul 28, 2017 at 4:11 PM, Dave Page  wrote:
>>>
>>>> Hi
>>>>
>>>> I took a quick look at this and have a couple of thoughts:
>>>>
>>>> - Instead of the "edit" icon to open the subnode, we should use
>>>> something more appropriate - a "properties" icon perhaps.
>>>>
>>>> - There seems to be a lot of different shades of grey on there (maybe a
>>>> subnode design in general that just shows up with the disabled controls),
>>>> and the subnode control looks a bit messy as a result.
>>>>
>>>> Can you work with Chethana to improve the look and feel please?
>>>>
>>>> Input from others welcome of course - screenshot attached.
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Jul 28, 2017 at 11:33 AM, Murtuza Zabuawala <
>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>
>>>>> ++ Attaching the patch
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Murtuza Zabuawala
>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>> On Fri, Jul 28, 2017 at 4:02 PM, Murtuza Zabuawala <
>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi Dave,
>>>>>>
>>>>>> PFA patch to display additional information from pg_stat_activity
>>>>>> table using subnode control.
>>>>>> RM#2597
>>>>>>
>>>>>> Please review.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Murtuza Zabuawala
>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Tue, Jul 25, 2017 at 10:56 AM, Shirley Wang 
>>>>>> wrote:
>>>>>>
>

Re: Can someone tell me what this code does ?

2017-08-09 Thread Murtuza Zabuawala
Hi,

On Wed, Aug 9, 2017 at 8:19 PM, Dave Cramer  wrote:

> So what is the policy of the project? Ideally the cruft should be removed.
>
> Would a patch doing so be committed?
>
​Yes, I guess.​

Dave Cramer
>
> On 9 August 2017 at 00:28, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Yes, you are correct, at a moment that's all it does.
>>
>> On Tue, Aug 8, 2017 at 6:37 PM, Dave Cramer  wrote:
>>
>>> Hi,
>>>
>>> I guess my question was a bit vague. I get that it loads drivers. But
>>> note it does not actually put them anywhere.
>>>
>>> First it creates a dict
>>> sets the attribute in the app
>>> loads the drivers dynamically
>>> and returns an empty dict.
>>>
>>> From what I can tell this:
>>>
>>> DriverRegistry.load_drivers()
>>>
>>> is all it does?
>>>
>>>
>>>
>>>
>>>
>>>
>>> Dave Cramer
>>>
>>> On 7 August 2017 at 23:35, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> This piece of code allow us to dynamically import all the available
>>>> driver modules from '../utils/driver/' directory into our application.
>>>>
>>>> --
>>>> Regards,
>>>> Murtuza Zabuawala
>>>> EnterpriseDB: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> [image: https://community.postgresrocks.net/]
>>>> <https://community.postgresrocks.net/>
>>>>
>>>> On Tue, Aug 8, 2017 at 4:20 AM, Dave Cramer 
>>>> wrote:
>>>>
>>>>> I'm fairly new to Python so excuse my naiveté.
>>>>>
>>>>> This code: in web/pgadmin/utils/driver/__init__.py  does not appear
>>>>> to load the drivers into the drivers dictionary ? Or am I missing 
>>>>> something
>>>>>
>>>>> def init_app(app):
>>>>> drivers = dict()
>>>>>
>>>>> setattr(app, '_pgadmin_server_drivers', drivers)
>>>>> DriverRegistry.load_drivers()
>>>>>
>>>>> return drivers
>>>>>
>>>>>
>>>>>
>>>>> Dave Cramer
>>>>>
>>>>
>>>>
>>>
>>
>


[pgAdmin4][PATCH] To fix pgAgent job step issues

2017-08-16 Thread Murtuza Zabuawala
Hi,

Please find attached patch to fix below given issues from pgAgent Jobs
Steps module.
1) 'Connection Type' cell was not honouring to 'Kind' option in Subnode
control.
2) Kind option was not saved properly
3) User was not be able to update Kind option in edit mode.
RM#2633

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
index 1a9653d..0c5a523 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
@@ -1,8 +1,8 @@
 define('pgadmin.node.pga_jobstep', [
   'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
   'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'alertify', 
'backform',
-  'pgadmin.backform'
-], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform) 
{
+  'backgrid', 'pgadmin.backform', 'pgadmin.backgrid'
+], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, Backform, 
Backgrid) {
 
   if (!pgBrowser.Nodes['coll-pga_jobstep']) {
 pgBrowser.Nodes['coll-pga_jobstep'] =
@@ -18,6 +18,40 @@ define('pgadmin.node.pga_jobstep', [
   });
   }
 
+  // Switch Cell with Deps, Needed for SubNode control
+  var SwitchDepsCell = Backgrid.Extension.SwitchCell.extend({
+initialize: function initialize() {
+  Backgrid.Extension.SwitchCell.prototype.initialize.apply(this, 
arguments);
+  Backgrid.Extension.DependentCell.prototype.initialize.apply(this, 
arguments);
+},
+dependentChanged: function dependentChanged() {
+  var model = this.model,
+  column = this.column,
+  editable = this.column.get("editable"),
+  input = this.$el.find('input[type=checkbox]').first(),
+  self_name = column.get('name'),
+  is_editable;
+
+  is_editable = _.isFunction(editable) ? !!editable.apply(column, [model]) 
: !!editable;
+  if (is_editable) {
+this.$el.addClass("editable");
+input.bootstrapSwitch('disabled', false);
+  } else {
+this.$el.removeClass("editable");
+input.bootstrapSwitch('disabled', true);
+// Set self value into model
+setTimeout(function () {
+  model.set(self_name, true);
+}, 10);
+
+  }
+
+  this.delegateEvents();
+  return this;
+},
+remove: Backgrid.Extension.DependentCell.prototype.remove
+  });
+
   if (!pgBrowser.Nodes['pga_jobstep']) {
 pgBrowser.Nodes['pga_jobstep'] = pgBrowser.Node.extend({
   parent_type: 'pga_job',
@@ -118,6 +152,11 @@ define('pgadmin.node.pga_jobstep', [
   id: 'jstconntype', label: gettext('Connection type'),
   type: 'switch', deps: ['jstkind'], mode: ['create', 'edit'],
   disabled: function(m) { return !m.get('jstkind'); },
+  cell: SwitchDepsCell,
+  editable: function(m) {
+// If jstkind is Batch then disable it
+return m.get('jstkind');
+  },
   options: {
 'onText': gettext('Local'), 'offText': gettext('Remote'),
 'onColor': 'primary', 'offColor': 'primary'
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
 
b/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
index 520d89f..45753af 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_jobstep.macros
@@ -14,10 +14,15 @@ INSERT INTO pgagent.pga_jobstep (
 ) {% if jid %}RETURNING jstid{% endif %};
 {%- endmacro %}
 {% macro UPDATE(has_connstr, jid, jstid, data) -%}
+{% if 'jstname' in data or 'jstenabled' in data or 'jstdesc' in data or 
'jstonerror' in data or 'jstcode' in data %}
+{% set is_colon_required = True %}
+{% else %}
+{% set is_colon_required = False %}
+{% endif %}
 -- Updating the existing step (id: {{ jstid|qtLiteral }} jobid: {{ 
jid|qtLiteral }})
 UPDATE pgagent.pga_jobstep
 SET
-{% if has_connstr %}{% if 'jstconntype' in data %}{% if data.jstconntype 
%}jstdbname={{ data.jstdbname|qtLiteral }}, jstconnstr=

[pgAdmin4][PATCH] Fix trigger's reversed engineered SQL for View

2017-08-18 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where view is not fully qualified in
Trigger definition.
RM#2560

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>
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 17a7df6..30d8dd9 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
@@ -901,6 +901,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
 # data.table and not data.relname so compatibility add new key as
 # table in res_rows.
 res_rows['table'] = res_rows['relname']
+res_rows['schema'] = self.view_schema
 
 # Get trigger function with its schema name
 SQL = render_template("/".join([self.trigger_temp_path,
@@ -999,6 +1000,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
 
 # merging formated result with main result again
 result.update(frmtd_reslt)
+self.view_schema = result.get('schema')
 
 # Fetch all privileges for view
 SQL = render_template("/".join(


[pgAdmin4][Patch]: To fix validation issue in connection string for pgAgent Job Step

2017-08-21 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where it was throwing error for valid
connection string if user passed host value as ip address.
RM#2655

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
index 0c5a523..72515a4 100644
--- 
a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
+++ 
b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.js
@@ -241,7 +241,7 @@ define('pgadmin.node.pga_jobstep', [
 } else {
   this.errorModel.unset('jstdbname');
   var msg,
-r = /\s*\b(\w+)\s*=\s*('([^'\\]*(?:\\.[^'\\]*)*)'|\w*)/g;
+r = /\s*\b(\w+)\s*=\s*('([^'\\]*(?:\\.[^'\\]*)*)'|[\w|\.]*)/g;
   val = this.get('jstconnstr');
   if (
 _.isUndefined(val) || _.isNull(val) ||


[pgAdmin4][Patch]: Update codemirror to latest version

2017-08-21 Thread Murtuza Zabuawala
Hi,

PFA patch to update CodeMirror to latest version(5.28.0
<https://codemirror.net/doc/releases.html>) which will fixes below listed
issues,

*Fixes:*
RM#1697
RM#2168
RM#2447
RM#2562

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>
diff --git a/web/package.json b/web/package.json
index 8e7fee3..a8cc950 100644
--- a/web/package.json
+++ b/web/package.json
@@ -55,7 +55,7 @@
 "bootstrap-switch": "3.3.2",
 "bowser": "1.6.1",
 "browserify": "~14.1.0",
-"codemirror": "^5.27.2",
+"codemirror": "^5.28.0",
 "css-loader": "0.14.0",
 "cssnano": "^3.10.0",
 "dropzone": "^5.1.1",


Re: pgAdmin4 - Tree view icons for final reveiw

2017-08-21 Thread Murtuza Zabuawala
Hi Chethana,

- The icons for Server node is missing, we will need given set of icons for
server.
1) Basic Server icon (Disconnect state)
2) PG (Connected state)
3) EPAS (Connected state)
4) GreenPlum (Connected state)
[Attaching current icons for PG & EPAS, I'm not sure about GreenPlum server
icon.]

- I'm not sure where we will use serverbad icon from 'tree_view_Icons.svg'
file as it looks like server-group icon and not individual server.

- Icon set for Schema & Catalog (both collection and individual) looks very
similar to each other with minor colour difference, we have to look very
carefully to identify them each.

- Why do we require two different set of icons for Tables & Columns, I mean
one for Schema and one for Catalog?

- Icons for Partition node is same for collection and individual.

- Icons for Event trigger node and Trigger node are very different from
each other despite both are triggers.

I know this is out of context but in my own opinion these icons have
resemblance with Flat design where as rest of our application is in 2d
design, for example buttons, dialogs etc.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Tue, Aug 22, 2017 at 9:37 AM, Chethana Kumar <
chethana.ku...@enterprisedb.com> wrote:

> Yes Shirley, I have already thought through on it.
> Basically, we need to have one more set of icons in white color mode so
> that we can use it on dialog headers as well.
> As the blue theme icons won't fit there.
>
> Please share your thoughts.
>
> Regards,
> Chethana kumar
>
> On Tue, Aug 22, 2017 at 4:32 AM, Shirley Wang  wrote:
>
>> Hi Chethana,
>>
>> I just thought of something with these icons. What happens with the ones
>> that appear in dialog headers? In the blue bar?
>>
>> On Mon, Aug 21, 2017 at 8:31 AM Chethana Kumar <
>> chethana.ku...@enterprisedb.com> wrote:
>>
>>> Hello Team,
>>>
>>> I have applied labels for each icon for identification purpose.  So
>>> please consider this copy for your feedback.
>>>
>>> *Note*: The "icon_demo.png" is attached to show case the view on
>>> webpage.
>>>
>>> Regards,
>>> Chethana kumar
>>>
>>> On Mon, Aug 21, 2017 at 3:57 PM, Chethana Kumar <
>>> chethana.ku...@enterprisedb.com> wrote:
>>>
>>>> Hello Team,
>>>>
>>>> Here are the revised and final icons for tree view control.
>>>> I have attached in .svg file format as well so that you can do zoom in
>>>> view at any level.
>>>>
>>>> Please share your feedback on the same.
>>>>
>>>>
>>>> Thanks and regards,
>>>>
>>>> Chethana Kumar
>>>> Principal UI/UX Designer
>>>> EnterpriseDB Corporation
>>>>
>>>>
>>>> The Postgres Database Company
>>>>
>>>> P: +91 86981 57146 <+91%2086981%2057146>
>>>> www.enterprisedb.com
>>>>
>>>
>>>
>>>
>>> --
>>> Chethana Kumar
>>> Principal UI/UX Designer
>>> EnterpriseDB Corporation
>>>
>>>
>>> The Postgres Database Company
>>>
>>> P: +91 86981 57146 <+91%2086981%2057146>
>>> www.enterprisedb.com
>>>
>>
>
>
> --
> Chethana Kumar
> Principal UI/UX Designer
> EnterpriseDB Corporation
>
>
> The Postgres Database Company
>
> P: +91 86981 57146
> www.enterprisedb.com
>


Re: [pgAdmin4][Patch]: RM_ 2658 - Improve help message for "binary paths" entered in Preferences

2017-08-22 Thread Murtuza Zabuawala
​​
https://redmine.postgresql.org/issues/2008
​

On Tue, Aug 22, 2017 at 7:14 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> On Tue, Aug 22, 2017 at 6:07 PM, Dave Page  wrote:
>
>>
>>
>> On Tue, Aug 22, 2017 at 1:30 PM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Hi
>>>
>>> *Issue:*
>>>
>>> The user seems to enter sometimes paths with quotes and sometimes add
>>> spaces which lead to failure of Backup, Restore or Maintenance utility.
>>>
>>> *Changes:*
>>>
>>>  - Added a note in help string `Note: Don't add quote(s) or space(s)
>>> before or after the path.`
>>>
>>>  - Remove whitespace before/after the value before it gets saved.
>>>
>>> Please find attached patch and review.
>>>
>>
>> I wonder if the more appropriate fix here would be to add a new setting
>> type (perhaps two, one for directory and one for file), which is rendered
>> with a browse button in the prefs panel, and includes real validation.
>>
> ​Yes, the suggested way is a better way.
> I will check what changes we have to made in preferences code to add
> support for new setting type and validations.
>
>>
>> Stripping spaces and warning about quotes seems like it's just kicking
>> the basic problem down the road a few feet.
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


Re: pgAdmin4 - Tree view icons for final reveiw

2017-08-23 Thread Murtuza Zabuawala
Hi Chethana,


On Wed, Aug 23, 2017 at 12:51 PM, Chethana Kumar <
chethana.ku...@enterprisedb.com> wrote:

> Hi Murtuza,
>
> Please see my reply inline along with the updated .svg file for tree view
> icons.
>
>
> On Tue, Aug 22, 2017 at 11:17 AM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Chethana,
>>
>> - The icons for Server node is missing, we will need given set of icons
>> for server.
>> 1) Basic Server icon (Disconnect state)
>> 2) PG (Connected state)
>> 3) EPAS (Connected state)
>> 4) GreenPlum (Connected state)
>> [Attaching current icons for PG & EPAS, I'm not sure about GreenPlum
>> server icon.]
>>
>> - I'm not sure where we will use serverbad icon from
>> 'tree_view_Icons.svg' file as it looks like server-group icon and not
>> individual server.
>>
>  The icon is there in the pgAdmin's icon folder and it is needed for the
> application
>
​Yes, we need serverbad icon which indicates the server in disconnect state
but what we have on svg is same icon as server-group icon, we need icon for
individual server.​

[image: Inline image 1]

​Something like this below which will differentiate individual server icon
from server-group icon,
[image: Inline image 6]​


>> - Icon set for Schema & Catalog (both collection and individual) looks
>> very similar to each other with minor colour difference, we have to look
>> very carefully to identify them each.
>>
>  Agree with this point and come up with some updations on it. This time I
> have made it pretty differentiable between Schema and Catalog.
>
>>
>> - Why do we require two different set of icons for Tables & Columns, I
>> mean one for Schema and one for Catalog?
>>
>  Agreed, I have kept single icon for tables and columns.
>
>>
>> - Icons for Partition node is same for collection and individual.
>>
>  Working on it
>
>>
>> - Icons for Event trigger node and Trigger node are very different from
>> each other despite both are triggers.
>>
>   Agreed, done the changes accordingly.
>
​This is still different.

*Current Event trigger icon:*
[image: Inline image 4]
*New​ **Event trigger*
*​ Icon:*
[image: Inline image 2]​


*Current Trigger icon:*

*[image: Inline image 5]*
*New Trigger Icon:*
[image: Inline image 3]
​If you see both icons are same.
*[Suggestion: Can we do similar to what we have done with View &
Materialized view icons, we have added M in the icon for materialized view,
Same way we can have Trigger icon and for Event trigger we can add E in the
icon]*


> I know this is out of context but in my own opinion these icons have
>> resemblance with Flat design where as rest of our application is in 2d
>> design, for example buttons, dialogs etc.
>>
> Yes, the icons look and feel are more towards flat and stylish now as it
> represents the current trend.  You treat this as a first step towards
> making the whole application flat design from the current design. But
> this will happen in a long run, not on a quick basis.
>
>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>>
>> On Tue, Aug 22, 2017 at 9:37 AM, Chethana Kumar <
>> chethana.ku...@enterprisedb.com> wrote:
>>
>>> Yes Shirley, I have already thought through on it.
>>> Basically, we need to have one more set of icons in white color mode so
>>> that we can use it on dialog headers as well.
>>> As the blue theme icons won't fit there.
>>>
>>> Please share your thoughts.
>>>
>>> Regards,
>>> Chethana kumar
>>>
>>> On Tue, Aug 22, 2017 at 4:32 AM, Shirley Wang  wrote:
>>>
>>>> Hi Chethana,
>>>>
>>>> I just thought of something with these icons. What happens with the
>>>> ones that appear in dialog headers? In the blue bar?
>>>>
>>>> On Mon, Aug 21, 2017 at 8:31 AM Chethana Kumar <
>>>> chethana.ku...@enterprisedb.com> wrote:
>>>>
>>>>> Hello Team,
>>>>>
>>>>> I have applied labels for each icon for identification purpose.  So
>>>>> please consider this copy for your feedback.
>>>>>
>>>>> *Note*: The "icon_demo.png" is attached to show case the view on
>>>>> webpage.
>>>>>
>>>>> Regards,
>>>>> Chethana kumar
>>>>>
>>>>> On Mon, Aug 21, 2017 at 3:57 PM, Chethana Kumar <

[pgAdmin4][Patch]: Allow user to provide custom SSL certificates and provide .pgpass file

2017-08-24 Thread Murtuza Zabuawala
Hi,

PFA patch to allow user to provide custom path for SSL certificates and
also allow user to pass .pgpass file when making server connection.
RM#2649
RM#2650

*SSL certificates options reference:*
https://www.postgresql.org/docs/10/static/libpq-connect.html
https://www.postgresql.org/docs/9.1/static/ssl-tcp.html

*.pgpass file reference:*
https://www.postgresql.org/docs/10/static/libpq-pgpass.html


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>
diff --git a/web/migrations/versions/ef590e979b0d_.py 
b/web/migrations/versions/ef590e979b0d_.py
new file mode 100644
index 000..be219c5
--- /dev/null
+++ b/web/migrations/versions/ef590e979b0d_.py
@@ -0,0 +1,46 @@
+
+"""empty message
+
+Revision ID: ef590e979b0d
+Revises: d85a62333272
+Create Date: 2017-08-23 18:37:14.836988
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from pgadmin.model import db
+
+# revision identifiers, used by Alembic.
+revision = 'ef590e979b0d'
+down_revision = 'd85a62333272'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+db.engine.execute(
+'ALTER TABLE server ADD COLUMN passfile TEXT'
+)
+db.engine.execute(
+'ALTER TABLE server ADD COLUMN sslcert TEXT'
+)
+db.engine.execute(
+'ALTER TABLE server ADD COLUMN sslkey TEXT'
+)
+db.engine.execute(
+'ALTER TABLE server ADD COLUMN sslrootcert TEXT'
+)
+db.engine.execute(
+'ALTER TABLE server ADD COLUMN sslcrl TEXT'
+)
+db.engine.execute(
+'ALTER TABLE server ADD COLUMN sslcompression '
+'INTEGER default 0'
+)
+db.engine.execute(
+'UPDATE server SET sslcompression=0'
+)
+
+
+def downgrade():
+pass
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py 
b/web/pgadmin/browser/server_groups/servers/__init__.py
index a74436e..d21a8f6 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -230,7 +230,29 @@ class ServerNode(PGChildNodeView):

'((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$'
 pat4 = re.compile(EXP_IP4)
 pat6 = re.compile(EXP_IP6)
+SSL_MODES = ['require', 'verify-ca', 'verify-full']
 
+def check_ssl_fields(self, data):
+"""
+This function will allow us to check and set defaults for
+SSL fields
+
+Args:
+data: Response data
+
+Returns:
+Flag and Data
+"""
+flag = False
+if 'sslmode' in data and data['sslmode'] in self.SSL_MODES:
+flag = True
+ssl_fields = [
+'sslcert', 'sslkey', 'sslrootcert', 'sslcrl', 'sslcompression'
+]
+for field in ssl_fields:
+if field not in data:
+data[field] = None
+return flag, data
 
 def nodes(self, gid):
 res = []
@@ -381,7 +403,13 @@ class ServerNode(PGChildNodeView):
 'gid': 'servergroup_id',
 'comment': 'comment',
 'role': 'role',
-'db_res': 'db_res'
+'db_res': 'db_res',
+'passfile': 'passfile',
+'sslcert': 'sslcert',
+'sslkey': 'sslkey',
+'sslrootcert': 'sslrootcert',
+'sslcrl': 'sslcrl',
+'sslcompression': 'sslcompression'
 }
 
 disp_lbl = {
@@ -411,8 +439,6 @@ class ServerNode(PGChildNodeView):
 errormsg=gettext('Host address not valid')
 )
 
-
-
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
 conn = manager.connection()
 connected = conn.connected()
@@ -430,7 +456,12 @@ class ServerNode(PGChildNodeView):
 
 for arg in config_param_map:
 if arg in data:
-setattr(server, config_param_map[arg], data[arg])
+value = data[arg]
+# sqlite3 do not have boolean type so we need to convert
+# it manually to integer
+if arg == 'sslcompression':
+value = 1 if value else 0
+setattr(server, config_param_map[arg], value)
 idx += 1
 
 if idx == 0:
@@ -532,6 +563,8 @@ class ServerNode(PGChildNodeVi

Re: Next release

2017-08-24 Thread Murtuza Zabuawala
+1 to 2.0

--
Thanks,
Murtuza

On Thu, Aug 24, 2017 at 3:06 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi Dave,
>
> On Thu, Aug 24, 2017 at 2:28 PM, Dave Page  wrote:
>
>> Anyone object to doing a release on 14th September, wrapping the code on
>> Monday 11th? This seems like the best option for our QA folks who will be
>> off for EID somewhen in the two weeks before.
>>
>> Assuming not, should this be 1.7 or 2.0?
>>
>> If we go with 2.0, it'll be for "safety" given the proposed changes to
>> path management to allow both server and desktop modes to work out of the
>> box on Linux.
>>
>> If we do that, we also need to ensure that any changes to the config
>> database are backwards compatible, as a 2.0 release would be a side-by-side
>> installation. Surinder; was it you that had looked into that?
>>
> ​I had looked into this and here are my findings:
> 1. If we are using newer version of pgAdmin and the go back to older
> version of pgAdmin, then on running `python pgAdmin4.py`. the
> flask-migrate(Alembic) try to perform downgrade by one step only(ie. it can
> switch back to one migration only when we run  `python pgAdmin4.py`). But
> we have multiple database revisions to be migrated. So migration fails here.
>
> 2. When Alebmic downgrade is performed by one step, it looks for downgrade
> function in that specific database revision, but in our code we didn't
> written downgrade function. But if we have written downgrade statement,
> still there is an issue:
> ie. If we add a new column to a table xyz using ALTER statement like:
>
> ​```
> ​
> def upgrade():
> ​​
> verison = get_version()
>
> ​​
> db.engine.execute(
> ​​
> 'ALTER TABLE server ADD COLUMN hostaddr TEXT(1024)'
> ​ ​
> )
>
> def downgrade():
> ​​
> pass
> ​```​
> then on downgrade it executes `downgrade` method, so downgrade should have
> code like
> `ALTER TABLE server DROP COLUMN hostaddr `
> but in sqlite DROP COLUMN statements don't work.
> So, this is a an issue with Sqlite database. However, an alternative way
> is also given. Here is link
> 
>
>
> Still, I didn't find any other solution on upgrading/downgrading database
> revisions without errors.
> It is an issue with Flask-Migrate(Alembic) plugin.
>
>
>> Comments/thoughts?
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


  1   2   3   4   5   >