[pgAdmin4][Patch]: Do not render security URL in templates if running in Desktop mode

2017-12-14 Thread Murtuza Zabuawala
Hi,

PFA patch to fix the issue where we were rendering Security URL's like
change password, reset password in HTML templates while running in Desktop
mode, we only register these security blueprints in Server mode hence it
was failing with BuildError.
RM#2952

Also reverted RM#2922 because it not working as expected and causing
runtime to render login screen.


Thanks to Neel for helping me in testing the patch with latest runtime code.


--
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 b21d530..0196852 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -540,9 +540,7 @@ def create_app(app_name=None):
 ):
 abort(401)
 
-if not config.SERVER_MODE:
-@app.before_first_request
-def before_first_request():
+if not config.SERVER_MODE:
 user = user_datastore.get_user(config.DESKTOP_USER)
 
 # Throw an error if we failed to find the desktop user, to give
diff --git a/web/pgadmin/templates/security/change_password.html 
b/web/pgadmin/templates/security/change_password.html
index 33bb834..48cb8cd 100644
--- a/web/pgadmin/templates/security/change_password.html
+++ b/web/pgadmin/templates/security/change_password.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('%(appname)s Password Change', 
appname=config.APP_NAME) }}{% endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 
 {{ change_password_form.hidden_tag() }}
 
@@ -10,4 +11,5 @@
 
 
 
+{% endif %}
 {% endblock %}
diff --git a/web/pgadmin/templates/security/forgot_password.html 
b/web/pgadmin/templates/security/forgot_password.html
index 3b90b3c..4b9d4c8 100644
--- a/web/pgadmin/templates/security/forgot_password.html
+++ b/web/pgadmin/templates/security/forgot_password.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('Recover %(appname)s Password', 
appname=config.APP_NAME) }}{% endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 {{ _('Enter the email address for the user account you wish to recover the 
password for:') }}
 
 {{ forgot_password_form.hidden_tag() }}
@@ -9,4 +10,5 @@
 
 
 
+{% endif %}
 {% endblock %}
diff --git a/web/pgadmin/templates/security/login_user.html 
b/web/pgadmin/templates/security/login_user.html
index 8c14a5b..cae4398 100644
--- a/web/pgadmin/templates/security/login_user.html
+++ b/web/pgadmin/templates/security/login_user.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('%(appname)s Login', appname=config.APP_NAME) }}{% 
endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 
 {{ login_user_form.hidden_tag() }}
 {% set user_language = request.cookies.get('PGADMIN_LANGUAGE') or 'en' %}
@@ -21,4 +22,5 @@
 
 
 {{ _('Forgotten your password?', url=url_for('browser.forgot_password')) }}
+{% endif %}
 {% endblock %}
diff --git a/web/pgadmin/templates/security/reset_password.html 
b/web/pgadmin/templates/security/reset_password.html
index 67dfff6..7bd8113 100644
--- a/web/pgadmin/templates/security/reset_password.html
+++ b/web/pgadmin/templates/security/reset_password.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('%(appname)s Password Reset', 
appname=config.APP_NAME) }}{% endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 
 {{ reset_password_form.hidden_tag() }}
@@ -10,4 +11,5 @@
 
 
 
+{% endif %}
 {% endblock %}


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

2017-12-14 Thread Murtuza Zabuawala
Yes, we can commit this code, It will add basic button navigation via Tab
key.

I will keep the RM open until we add Tab navigation :)


On Wed, Dec 13, 2017 at 9:33 PM, Dave Page  wrote:

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


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

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

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

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


Re: [pgAdmin4][Patch]: Do not render security URL in templates if running in Desktop mode

2017-12-14 Thread Harshal Dhumal
Hi Murtuza,

Moving login related code from under  decorator @app.before_first_request
to @app.before_request
will cause runtime user to login on each request. I think we need to find
some better way.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Thu, Dec 14, 2017 at 2:02 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix the issue where we were rendering Security URL's like
> change password, reset password in HTML templates while running in Desktop
> mode, we only register these security blueprints in Server mode hence it
> was failing with BuildError.
> RM#2952
>
> Also reverted RM#2922 because it not working as expected and causing
> runtime to render login screen.
>
>
> Thanks to Neel for helping me in testing the patch with latest runtime
> code.
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>


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

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

>
>
> On Thu, Dec 14, 2017 at 2:07 PM, Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Yes, we can commit this code, It will add basic button navigation via Tab
>> key.
>>
>> I think we should hold till our final design gets ready.
>
​Adding 'tabindex' on button won't hurt in anyway and not become any kind
of hurdle in design.​


> I will keep the RM open until we add Tab navigation :)
>>
>>
>> On Wed, Dec 13, 2017 at 9:33 PM, Dave Page  wrote:
>>
>>> Hi,
>>>
>>> On Wed, Dec 13, 2017 at 7:55 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi,

 PFA patch to add basic Tab key navigation in debugger window, where
 user will be able to navigate buttons using Tab key.
 RM#2897

 TODO:// Need to work on Debugger window Panel navigation.

>>>
>>> Given our conversation this morning, do we still want to apply this at
>>> this time?
>>>
>>> (for the benefit of the list, Murtuza, Khushboo, Harshal and I were
>>> discussing a keyboard navigation strategy for the whole application).
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>


[pgAdmin4][Patch]: File manager - Allow user to load the file by double clicking on it

2017-12-14 Thread Murtuza Zabuawala
Hi,

PFA patch which will allow user to load the file via file manager by double
clicking on the file just like native file manager.
RM#2810

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js 
b/web/pgadmin/misc/file_manager/static/js/utility.js
index 99e632f..95e57e1 100755
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -923,7 +923,10 @@ var getFolderInfo = function(path, file_type) {
 getFolderInfo(path);
 
   } else {
-getFileInfo(path);
+var is_valid_file = getFileInfo(path);
+if (is_valid_file && check_file_capability(e, data_cap, 'grid')) {
+  $('.file_manager_ok').click();
+}
   }
 });
 
@@ -1032,7 +1035,10 @@ var getFolderInfo = function(path, file_type) {
 $('.file_manager button.delete, .file_manager 
button.rename').attr('disabled', 'disabled');
 getFolderInfo(path);
   } else {
-getFileInfo(path);
+var is_valid_file = getFileInfo(path), is_protected;
+if (is_valid_file && check_file_capability(e, data_cap, 'table')) {
+  $('.file_manager_ok').click();
+}
   }
 });
 
@@ -1065,6 +1071,30 @@ var enab_dis_level_up = function() {
   }, 100);
 };
 
+// Check if user can Select file
+var check_file_capability = function(event, data_cap, view_type) {
+  var current_element = event.currentTarget,
+  path, file_name, is_protected;
+
+  if (view_type == 'grid') {
+path = decodeURI($(current_element).find('.clip span').attr('data-alt')),
+file_name = $(current_element).find('p span').attr('title'),
+is_protected = $(current_element).find(
+  '.clip span.fm_lock_icon'
+).attr('data-protected');
+  } else {
+path = decodeURI($(current_element).find('td:first-child').attr('title')),
+file_name = decodeURI($(current_element).find('td:first-child p 
span').attr(
+  'title'
+)),
+is_protected = $(current_element).find('td:first-child').find(
+  'i.tbl_lock_icon'
+).attr('data-protected');
+  }
+
+  return has_capability(data_cap, 'select_file') && is_protected == undefined;
+}
+
 /*-
   Initialization - Entry point
 -*/


[pgAdmin4][Patch]: Allow user to select error text

2017-12-14 Thread Murtuza Zabuawala
Hi,

PFA minor patch which will allow user to select the text from error message.
RM#2954

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/static/scss/_alert.scss 
b/web/pgadmin/static/scss/_alert.scss
index 441c40f..64e5617 100644
--- a/web/pgadmin/static/scss/_alert.scss
+++ b/web/pgadmin/static/scss/_alert.scss
@@ -106,6 +106,11 @@
 border: 1px solid $color-red-2;
 padding: 7px 12px 6px 10px;
 border-left: none;
+-moz-user-select: text;
+-khtml-user-select: text;
+-webkit-user-select: text;
+-ms-user-select: text;
+user-select: text;
   }
 
   .error-in-footer {


Re: [pgAdmin4][Patch]: Do not render security URL in templates if running in Desktop mode

2017-12-14 Thread Murtuza Zabuawala
Yes Harshal, you are right but due to RM#2922 changes now runtime is
rendering the Login page.

@Dave,
Please find updated patch, which will also fix the issue of user login on
each request in runtime.
RM#2952
RM#2922

--
​ ​
Murtuza

On Thu, Dec 14, 2017 at 2:25 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Murtuza,
>
> Moving login related code from under  decorator @app.before_first_request
> to @app.before_request
> will cause runtime user to login on each request. I think we need to find
> some better way.
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Dec 14, 2017 at 2:02 PM, Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix the issue where we were rendering Security URL's like
>> change password, reset password in HTML templates while running in Desktop
>> mode, we only register these security blueprints in Server mode hence it
>> was failing with BuildError.
>> RM#2952
>>
>> Also reverted RM#2922 because it not working as expected and causing
>> runtime to render login screen.
>>
>>
>> Thanks to Neel for helping me in testing the patch with latest runtime
>> code.
>>
>>
>> --
>> 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 b21d530..db676c5 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -540,11 +540,8 @@ def create_app(app_name=None):
 ):
 abort(401)
 
-if not config.SERVER_MODE:
-@app.before_first_request
-def before_first_request():
+if not config.SERVER_MODE and not current_user.is_authenticated:
 user = user_datastore.get_user(config.DESKTOP_USER)
-
 # Throw an error if we failed to find the desktop user, to give
 # the sysadmin a hint. We'll continue to try to login anyway as
 # that'll through a nice 500 error for us.
@@ -554,7 +551,6 @@ def create_app(app_name=None):
 % config.DESKTOP_USER
 )
 abort(401)
-
 login_user(user)
 
 @app.after_request
diff --git a/web/pgadmin/templates/security/change_password.html 
b/web/pgadmin/templates/security/change_password.html
index 33bb834..48cb8cd 100644
--- a/web/pgadmin/templates/security/change_password.html
+++ b/web/pgadmin/templates/security/change_password.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('%(appname)s Password Change', 
appname=config.APP_NAME) }}{% endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 
 {{ change_password_form.hidden_tag() }}
 
@@ -10,4 +11,5 @@
 
 
 
+{% endif %}
 {% endblock %}
diff --git a/web/pgadmin/templates/security/forgot_password.html 
b/web/pgadmin/templates/security/forgot_password.html
index 3b90b3c..4b9d4c8 100644
--- a/web/pgadmin/templates/security/forgot_password.html
+++ b/web/pgadmin/templates/security/forgot_password.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('Recover %(appname)s Password', 
appname=config.APP_NAME) }}{% endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 {{ _('Enter the email address for the user account you wish to recover the 
password for:') }}
 
 {{ forgot_password_form.hidden_tag() }}
@@ -9,4 +10,5 @@
 
 
 
+{% endif %}
 {% endblock %}
diff --git a/web/pgadmin/templates/security/login_user.html 
b/web/pgadmin/templates/security/login_user.html
index 8c14a5b..cae4398 100644
--- a/web/pgadmin/templates/security/login_user.html
+++ b/web/pgadmin/templates/security/login_user.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('%(appname)s Login', appname=config.APP_NAME) }}{% 
endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 
 {{ login_user_form.hidden_tag() }}
 {% set user_language = request.cookies.get('PGADMIN_LANGUAGE') or 'en' %}
@@ -21,4 +22,5 @@
 
 
 {{ _('Forgotten your password?', url=url_for('browser.forgot_password')) }}
+{% endif %}
 {% endblock %}
diff --git a/web/pgadmin/templates/security/reset_password.html 
b/web/pgadmin/templates/security/reset_password.html
index 67dfff6..7bd8113 100644
--- a/web/pgadmin/templates/security/reset_password.html
+++ b/web/pgadmin/templates/security/reset_password.html
@@ -1,6 +1,7 @@
 {% extends "security/panel.html" %}
 {% block panel_title %}{{ _('%(appname)s Password Reset', 
appname=config.APP_NAME) }}{% endblock %}
 {% block panel_body %}
+{% if config.SERVER_MODE %}
 
 {{ reset_password_form.hidden_tag() }}
@@ -10,4 +11,5 @@
 
 
 
+{% endif %}
 {% endblock %}


Re: Enums printout - possible bug

2017-12-14 Thread Harshal Dhumal
+pgadmin-hackers

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Thu, Dec 14, 2017 at 5:26 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please find attached patch for various data type test cases.
>
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Mon, Dec 11, 2017 at 5:24 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Sat, Dec 9, 2017 at 12:06 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Sat, Dec 9, 2017 at 11:50 AM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>

 On Sat, Dec 9, 2017 at 11:30 AM, Dave Page  wrote:

> Hi
>
> Yeah, that one is in my list to work on. Have you specifically tested
> it with enum types (not enum[])?
>

 Yes.

>>>
>>> @Harshal,
>>>
>>> Can you add multidimensional array, enum types into feature test
>>> (pg_datatype_validation_test.py) ?
>>>
>>
>> I think I need to add test cases for all array data types not just enum
>> types since fix was not targeted for any particular data type.
>>
>>
>>>
>>> [image: Inline image 3]



>
> On Sat, Dec 9, 2017 at 5:55 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Recently I sent a patch
>> 
>> regarding multidimensional array representation issue.
>> In that patch I have reworked about how multidimensional (1 dimension
>> to n dimension)
>> array data should be represented in grid.
>> Also this patch covers almost all the array data types including
>> composite array data types like
>> int8range[], enum[], inet[], cidr[], macaddr[], uuid[], xml[], bit[],
>> varbit[] and so on.
>>
>> Please review the patch and let me know if any thing needs to be
>> included in this patch.
>>
>> Thanks,
>>
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Sat, Dec 9, 2017 at 10:45 AM, Dave Page  wrote:
>>
>>> Murtuza, can you investigate please?
>>>
>>> Thanks!
>>>
>>> On Fri, Dec 8, 2017 at 8:08 PM, Bartosz Dmytrak 
>>> wrote:
>>>
 Hi all,

 According to documentation: https://www.postgresql.org/doc
 s/current/static/functions-enum.html when I execute SELECT
 enum_range(null::rainbow) then output should look like this:
 {red,orange,yellow,green,blue,purple}

 But in pgAdmin output looks like this:
 {{,r,e,d,,,o,r,a,n,g,e,,,y,e,l,l,o,w,,,g,r,e,e,n,,,b,l,u,e,,,p,u,r,p,l,e,}}.
 When you click on the field, popup window shows correct value. I’ve 
 double
 checked it in psql, and output is correct. I think it could be 
 considered
 as bug in pgAdmin



 PgAdmin details:

 *Version *2.0

 *Python Version *2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016,
 20:42:59) [MSC v.1500 32 bit (Intel)]

 *Flask Version *0.12.2

 *Application Mode *Desktop



 Pg Version: 10.1

 Regardless this one, many thanks for your great job pgAdmin Team!





 Best regards,

 *Bartosz Dmytrak*



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


>>>
>>
>