[pgAdmin4][RM#3037] Allow user to disable Gravatar image

2018-03-05 Thread Murtuza Zabuawala
Hi,

PFA patch to disable Gravatar image in Server mode.

Requirments & Issues:
- For security reasons.
- For systems which do not have internet access.
- Hangs pgAdmin4 while loading the page if connection has no internet
access (as described in the ticket)

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


RM_3037.diff
Description: Binary data


[pgAdmin4][RM#3175] Fix PEP-8 issues

2018-03-05 Thread Murtuza Zabuawala
Hi,

PFA patch to fix PEP8 issues in Browser & Database modules,
pycodestyle --config=.pycodestyle pgadmin/browser/__init__.py
pycodestyle --config=.pycodestyle pgadmin/browser/tests/
pycodestyle --config=.pycodestyle
pgadmin/browser/server_groups/servers/databases/__init__.py
pycodestyle --config=.pycodestyle
pgadmin/browser/server_groups/servers/databases/tests/



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


RM_3175.diff
Description: Binary data


[pgadmin4][patch] GreenPlum function statistics through an exception

2018-03-05 Thread Joao De Almeida Pereira
Hi Hackers,
You can find attached the resolution for issue 3176.
When trying to retrieve the statistics from a function in a GreenPlum
database an error is displayed, To fix this for version 5.X we decided to
remove the ability to get statistics.

Thanks
Joao
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js
index 7622cd0b..6e405165 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.js
@@ -92,7 +92,9 @@ define('pgadmin.node.function', [
   collection_type: 'coll-function',
   hasSQL: true,
   hasDepends: true,
-  hasStatistics: true,
+  hasStatistics: (treeInformation) => {
+return treeInformation.server.server_type !== 'gpdb';
+  },
   hasScriptTypes: ['create', 'select'],
   parent_type: ['schema', 'catalog'],
   Init: function() {
diff --git a/web/pgadmin/misc/statistics/static/js/statistics.js b/web/pgadmin/misc/statistics/static/js/statistics.js
index 39ff7bb3..3ff88a0a 100644
--- a/web/pgadmin/misc/statistics/static/js/statistics.js
+++ b/web/pgadmin/misc/statistics/static/js/statistics.js
@@ -1,8 +1,10 @@
 define('misc.statistics', [
   'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'backbone',
   'pgadmin.browser', 'pgadmin.backgrid', 'alertify', 'sources/size_prettify',
+  'sources/misc/statistics/statistics',
 ], function(
-  gettext, _, S, $, Backbone, pgBrowser, Backgrid, Alertify, sizePrettify
+  gettext, _, S, $, Backbone, pgBrowser, Backgrid, Alertify, sizePrettify,
+  statisticsHelper
 ) {
 
   if (pgBrowser.NodeStatistics)
@@ -208,7 +210,7 @@ define('misc.statistics', [
 // Cache the current IDs for next time
 $(panel[0]).data('node-prop', cache_flag);
 
-if (node.hasStatistics) {
+if (statisticsHelper.nodeHasStatistics(node, item)) {
   msg = '';
   var timer;
   // Set the url, fetch the data and update the collection
diff --git a/web/pgadmin/static/js/misc/statistics/statistics.js b/web/pgadmin/static/js/misc/statistics/statistics.js
new file mode 100644
index ..2aabc75b
--- /dev/null
+++ b/web/pgadmin/static/js/misc/statistics/statistics.js
@@ -0,0 +1,15 @@
+//
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2018, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//
+export function nodeHasStatistics(node, item) {
+  if(typeof(node.hasStatistics) === 'function') {
+const treeHierarchy = node.getTreeNodeHierarchy(item);
+return node.hasStatistics(treeHierarchy);
+  }
+  return node.hasStatistics;
+}
diff --git a/web/regression/javascript/misc/statistics/statistics_spec.js b/web/regression/javascript/misc/statistics/statistics_spec.js
new file mode 100644
index ..87540d10
--- /dev/null
+++ b/web/regression/javascript/misc/statistics/statistics_spec.js
@@ -0,0 +1,35 @@
+//
+//
+// pgAdmin 4 - PostgreSQL Tools
+//
+// Copyright (C) 2013 - 2018, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//
+import {nodeHasStatistics} from "../../../../pgadmin/static/js/misc/statistics/statistics";
+
+describe('#nodeHasStatistics', () => {
+  describe('when node hasStatistics is not a function', () => {
+it('return the value of hasStatistics', () => {
+  const node = {
+hasStatistics: true,
+  };
+  expect(nodeHasStatistics(node, {})).toBe(true);
+});
+  });
+
+  describe('when node hasStatistics is a function', () => {
+describe('when the function returns true', () => {
+  it('returns true', () => {
+const node = {
+  hasStatistics: () => true,
+  getTreeNodeHierarchy: jasmine.createSpy(),
+};
+const item = {};
+
+expect(nodeHasStatistics(node, item)).toBe(true);
+expect(node.getTreeNodeHierarchy).toHaveBeenCalledWith(item);
+  });
+});
+  });
+});


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

2018-03-05 Thread Joao De Almeida Pereira
Hello Khushboo,
Looks like we are almost doen, just missing one PEP-8 issue:
→ pycodestyle --config=.pycodestyle pgadmin/tools
pgadmin/tools/sqleditor/tests/test_poll_query_tool.py:46: [E126]
continuation line over-indented for hanging indent
1   E126 continuation line over-indented for hanging indent
1


The tests run successfully in our CI pipeline.

Thanks
Joao

On Sun, Mar 4, 2018 at 11:51 PM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> On Fri, Mar 2, 2018 at 6:55 PM, Dave Page  wrote:
>
>> Could you rebase this please? It no longer applies.
>>
>> Please find the attached updated patch.
>
>> Thanks.
>>
>> On Thu, Mar 1, 2018 at 5:56 AM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi Joao,
>>>
>>> Thanks for reviewing.
>>>
>>> On Wed, Feb 28, 2018 at 8:55 PM, Joao De Almeida Pereira <
>>> jdealmeidapere...@pivotal.io> wrote:
>>>
 Hello Khushboo,
 After reviewing the patch I have the gut feeling that we do not have
 enough test coverage on this issue, specially due to the intricate while
 loop and conditions around the polling.
 I think that this deserve Unit tests around it, When I say Unit Test I
 am not talking about executing queries against the database, but do some
 stubbing of the database so that we can control the flow that we want.

>>> You are right. It needs more unit testing. I have checked below
>>> scenarios:
>>> 1. Returns 2 notices with data output
>>> 2. Returns 1000 notices with data output
>>> 3. No notices with data output
>>>
>>> By running above, I have checked, each time returned notices are
>>> accurate, no old notices are getting appended, it does not affect with the
>>> amount of messages (few, none or more).  Also, with the updated patch, I
>>> have made sure that all these queries run with the single transaction id
>>> (same connection).
>>>
>>> So, please let me know if you think I can add more things to this.
>>>


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

 Right, so added regression tests instead of feature tests.
>>>
>>> This being said, I run the tests on the CI Pipeline and all tests pass.
 Running pycodestyle fails due to some line sizes on the
 psycopg2/__init__py. I believe that it is not what you changed, but since
 you were changing the file it can be fixed it is just:

 pgadmin/utils/driver/psycopg2/__init__.py:1276: [E501] line too long
 (81 > 79 characters)
 pgadmin/utils/driver/psycopg2/__init__.py:1277: [E501] line too long
 (91 > 79 characters)
 pgadmin/utils/driver/psycopg2/__init__.py:1282: [E501] line too long
 (81 > 79 characters)
 pgadmin/utils/driver/psycopg2/__init__.py:1283: [E501] line too long
 (91 > 79 characters)
 4   E501 line too long (81 > 79 characters)

 Fixed. Thanks for pointing out.
>>>

 Thanks
 Joao


 On Wed, Feb 28, 2018 at 6:49 AM Khushboo Vashi <
 khushboo.va...@enterprisedb.com> wrote:

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

>

Re: [pgAdmin4][RM#3037] Allow user to disable Gravatar image

2018-03-05 Thread Joao De Almeida Pereira
Hi Murtuza,

Why are we doing this using templates? Can this be done with a request to
the backend to get the image and then retrieve the Gravatar if it is
defined or return a static image if not?

+
+{% if config.SERVER_MODE %}
 window.onload = function(e){
  setTimeout(function() {
-   var gravatarImg = ' {{ username }} ';
+   var gravatarImg = {{ IMG.PREPARE_HTML()|safe }}
//$('#navbar-menu .navbar-right > li > a').html(gravatarImg);
var navbarRight =
document.getElementById("navbar-menu").getElementsByClassName("navbar-right")[0];
if (navbarRight) {

what if we have

var gravatarImg = ' {{ username }} ';

And then the endpoint
/user/{{username}}/gravatar
would be responsible for returning a Gravatar or not depending on the
configuration?


Thanks
Joao

On Mon, Mar 5, 2018 at 3:13 AM Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to disable Gravatar image in Server mode.
>
> Requirments & Issues:
> - For security reasons.
> - For systems which do not have internet access.
> - Hangs pgAdmin4 while loading the page if connection has no internet
> access (as described in the ticket)
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>


Re: [pgAdmin4][RM#3175] Fix PEP-8 issues

2018-03-05 Thread Joao De Almeida Pereira
Hi Murtuza,

Looks good, and all tests are green. I run the commands provided and
nothing pops up.

Only missing 374 :D

Thanks
Joao

On Mon, Mar 5, 2018 at 7:09 AM Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix PEP8 issues in Browser & Database modules,
> pycodestyle --config=.pycodestyle pgadmin/browser/__init__.py
> pycodestyle --config=.pycodestyle pgadmin/browser/tests/
> pycodestyle --config=.pycodestyle
> pgadmin/browser/server_groups/servers/databases/__init__.py
> pycodestyle --config=.pycodestyle
> pgadmin/browser/server_groups/servers/databases/tests/
>
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>


Re: [pgAdmin4][RM#3037] Allow user to disable Gravatar image

2018-03-05 Thread Murtuza Zabuawala
Hi Joao,

We are using Flask-Gravatar 
module for this and it is designed to work with template only.

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


On Mon, Mar 5, 2018 at 8:57 PM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hi Murtuza,
>
> Why are we doing this using templates? Can this be done with a request to
> the backend to get the image and then retrieve the Gravatar if it is
> defined or return a static image if not?
>
> +
> +{% if config.SERVER_MODE %}
>  window.onload = function(e){
>   setTimeout(function() {
> -   var gravatarImg = ' height="18" alt="Gravatar image for {{ username }}"> {{ username }}  class="caret">';
> +   var gravatarImg = {{ IMG.PREPARE_HTML()|safe }}
> //$('#navbar-menu .navbar-right > li > a').html(gravatarImg);
> var navbarRight = document.getElementById("navbar-menu").
> getElementsByClassName("navbar-right")[0];
> if (navbarRight) {
>
> what if we have
>
> var gravatarImg = ' height="18" alt="Gravatar image for {{ username }}"> {{ username }}  class="caret">';
>
> And then the endpoint
> /user/{{username}}/gravatar
> would be responsible for returning a Gravatar or not depending on the
> configuration?
>
>
> Thanks
> Joao
>
> On Mon, Mar 5, 2018 at 3:13 AM Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to disable Gravatar image in Server mode.
>>
>> Requirments & Issues:
>> - For security reasons.
>> - For systems which do not have internet access.
>> - Hangs pgAdmin4 while loading the page if connection has no internet
>> access (as described in the ticket)
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>


Re: [pgAdmin4][RM#3175] Fix PEP-8 issues

2018-03-05 Thread Murtuza Zabuawala
Thanks Joao for reviewing.


On Mon, Mar 5, 2018 at 8:58 PM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hi Murtuza,
>
> Looks good, and all tests are green. I run the commands provided and
> nothing pops up.
>
> Only missing 374 :D
>
​:-) ​


>
> Thanks
> Joao
>
> On Mon, Mar 5, 2018 at 7:09 AM Murtuza Zabuawala  enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to fix PEP8 issues in Browser & Database modules,
>> pycodestyle --config=.pycodestyle pgadmin/browser/__init__.py
>> pycodestyle --config=.pycodestyle pgadmin/browser/tests/
>> pycodestyle --config=.pycodestyle pgadmin/browser/server_groups/
>> servers/databases/__init__.py
>> pycodestyle --config=.pycodestyle pgadmin/browser/server_groups/
>> servers/databases/tests/
>>
>>
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>


Re: [pgAdmin4][RM#3037] Allow user to disable Gravatar image

2018-03-05 Thread Joao De Almeida Pereira
Hello,
I understand that, but what do we win by using it? As you have noticed by
now I am not very fond of using templates for everything, and I believe
this is one of the things that we can skip templates.
We might even shift this to a frontend concern and if we want there are
node libraries to get gravatars.

I was able to create a PoC as a sample of what I was talking about:
 - Add gravatar library to package.json
 - Created a Preferences cache. (js/preferences.js)
   - So this was the concept I was talking about in a previous email we
talked about caching.
  the getConfiguration and the getAllConfiguration are not great names,
but they return a Promise that is consumed in the load_gravatar. The idea
here is that we are caching the pgAdmin settings and when need need to
consume them, we wait for it to be available.
 - load_gravatar is using the pattern to retrieve the configuration from a
possible cache and then apply the gravatar


Things that need to be revisited in the PoC:
- No tests, just some spiked code
- Did not retrieve the username from the backend, we need to create an
endpoint that give us this
- The url is hardcoded to get the configuration
- Maybe the Preferences is not the correct place to get server_mode
configuration not sure, what do you think?


Thanks
Joao

On Mon, Mar 5, 2018 at 11:21 AM Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Joao,
>
> We are using Flask-Gravatar 
> module for this and it is designed to work with template only.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Mon, Mar 5, 2018 at 8:57 PM, Joao De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hi Murtuza,
>>
>> Why are we doing this using templates? Can this be done with a request to
>> the backend to get the image and then retrieve the Gravatar if it is
>> defined or return a static image if not?
>>
>> +
>> +{% if config.SERVER_MODE %}
>>  window.onload = function(e){
>>   setTimeout(function() {
>> -   var gravatarImg = '> height="18" alt="Gravatar image for {{ username }}"> {{ username }} > class="caret">';
>> +   var gravatarImg = {{ IMG.PREPARE_HTML()|safe }}
>> //$('#navbar-menu .navbar-right > li > a').html(gravatarImg);
>> var navbarRight =
>> document.getElementById("navbar-menu").getElementsByClassName("navbar-right")[0];
>> if (navbarRight) {
>>
>> what if we have
>>
>> var gravatarImg = '> height="18" alt="Gravatar image for {{ username }}"> {{ username }} > class="caret">';
>>
>> And then the endpoint
>> /user/{{username}}/gravatar
>> would be responsible for returning a Gravatar or not depending on the
>> configuration?
>>
>>
>> Thanks
>> Joao
>>
>> On Mon, Mar 5, 2018 at 3:13 AM Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to disable Gravatar image in Server mode.
>>>
>>> Requirments & Issues:
>>> - For security reasons.
>>> - For systems which do not have internet access.
>>> - Hangs pgAdmin4 while loading the page if connection has no internet
>>> access (as described in the ticket)
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>
diff --git a/web/package.json b/web/package.json
index 2707b334..8d62e7b5 100644
--- a/web/package.json
+++ b/web/package.json
@@ -66,6 +66,7 @@
 "exports-loader": "~0.6.4",
 "flotr2": "^0.1.0",
 "font-awesome": "^4.7.0",
+"gravatar": "^1.6.0",
 "hard-source-webpack-plugin": "^0.4.9",
 "immutability-helper": "^2.2.0",
 "imports-loader": "^0.7.1",
diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html
index 58ff43f8..0901f44a 100644
--- a/web/pgadmin/browser/templates/browser/index.html
+++ b/web/pgadmin/browser/templates/browser/index.html
@@ -5,6 +5,7 @@ try {
 require(
 ['sources/generated/app.bundle'],
 function() {
+pgAdmin.applyAvatar(pgAdmin);
 },
 function() {
 /* TODO:: Show proper error dialog */
@@ -66,17 +67,6 @@ require.onResourceLoad = function (context, map, depMaps) {
 }, 400)
   }
 };
-window.onload = function(e){
- setTimeout(function() {
-   var gravatarImg = ' {{ username }} ';
-   //$('#navbar-menu .navbar-right > li > a').html(gravatarImg);
-   var navbarRight = document.getElementById("navbar-menu").getElementsByClassName("navbar-right")[0];
-   if (navbarRight) {
- var list = navbarRight.getElementsByTagName("LI")[0];
- list.getElementsByTagName("a")[0].innerHTML = gravatarImg;
-   }
- }, 1000);
-};
 
 {% endblock %}
 {% block body %}
diff --git a/web/pgadmin/preferences/__init__.py b/web/pgadmin/preferences/__init__.py
index f1f571cd..e75aa4cb 100644
--- a/web/pgadmin/preferences/__init__.py
+++ b/web/pgadmin/preferences/__init__.py
@@ -21,6 +21,7 @@ from pgadmin.utils.ajax import success_return, \
 make_response as ajax_response, 

Re: [pgAdmin4][RM#3037] Allow user to disable Gravatar image

2018-03-05 Thread Murtuza Zabuawala
Hi Joao,

Your suggestion is good but in my own opinion it is overkill just to
replace code {{ username| gravatar }} as rest of the syntax is pure HTML,
This makes code much simpler and easy to understand.
Apart from that we will be rendering 'index.html' template anyways and I
don't see any extra overhead.

I may be wrong, Let's wait for the input from other community members.

Regards,
Murtuza

On Tue, Mar 6, 2018 at 1:17 AM, Joao De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hello,
> I understand that, but what do we win by using it? As you have noticed by
> now I am not very fond of using templates for everything, and I believe
> this is one of the things that we can skip templates.
> We might even shift this to a frontend concern and if we want there are
> node libraries to get gravatars.
>
> I was able to create a PoC as a sample of what I was talking about:
>  - Add gravatar library to package.json
>  - Created a Preferences cache. (js/preferences.js)
>- So this was the concept I was talking about in a previous email we
> talked about caching.
>   the getConfiguration and the getAllConfiguration are not great
> names, but they return a Promise that is consumed in the load_gravatar. The
> idea here is that we are caching the pgAdmin settings and when need need to
> consume them, we wait for it to be available.
>  - load_gravatar is using the pattern to retrieve the configuration from a
> possible cache and then apply the gravatar
>
>
> Things that need to be revisited in the PoC:
> - No tests, just some spiked code
> - Did not retrieve the username from the backend, we need to create an
> endpoint that give us this
> - The url is hardcoded to get the configuration
> - Maybe the Preferences is not the correct place to get server_mode
> configuration not sure, what do you think?
>
>
> Thanks
> Joao
>
> On Mon, Mar 5, 2018 at 11:21 AM Murtuza Zabuawala <
> murtuza.zabuaw...@enterprisedb.com> wrote:
>
>> Hi Joao,
>>
>> We are using Flask-Gravatar 
>> module for this and it is designed to work with template only.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> On Mon, Mar 5, 2018 at 8:57 PM, Joao De Almeida Pereira <
>> jdealmeidapere...@pivotal.io> wrote:
>>
>>> Hi Murtuza,
>>>
>>> Why are we doing this using templates? Can this be done with a request
>>> to the backend to get the image and then retrieve the Gravatar if it is
>>> defined or return a static image if not?
>>>
>>> +
>>> +{% if config.SERVER_MODE %}
>>>  window.onload = function(e){
>>>   setTimeout(function() {
>>> -   var gravatarImg = '>> height="18" alt="Gravatar image for {{ username }}"> {{ username }} >> class="caret">';
>>> +   var gravatarImg = {{ IMG.PREPARE_HTML()|safe }}
>>> //$('#navbar-menu .navbar-right > li > a').html(gravatarImg);
>>> var navbarRight = document.getElementById("navba
>>> r-menu").getElementsByClassName("navbar-right")[0];
>>> if (navbarRight) {
>>>
>>> what if we have
>>>
>>> var gravatarImg = '>> height="18" alt="Gravatar image for {{ username }}"> {{ username }} >> class="caret">';
>>>
>>> And then the endpoint
>>> /user/{{username}}/gravatar
>>> would be responsible for returning a Gravatar or not depending on the
>>> configuration?
>>>
>>>
>>> Thanks
>>> Joao
>>>
>>> On Mon, Mar 5, 2018 at 3:13 AM Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
 Hi,

 PFA patch to disable Gravatar image in Server mode.

 Requirments & Issues:
 - For security reasons.
 - For systems which do not have internet access.
 - Hangs pgAdmin4 while loading the page if connection has no internet
 access (as described in the ticket)

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


>>


Re: pgAdmin 4 commit: Support for external tables in GPDB. Fixes #3168

2018-03-05 Thread Neel Patel
Hi Joao,

I ran the testsuite in windows 10 with Python 3.4 and it fails for external
tables. Linux it is working fine. Let me know if I miss anything.

Please check the below logs.

python runtests.py --pkg browser --exclude feature_tests



==
ERROR: runTest
(pgadmin.browser.server_groups.servers.databases.schemas.tables.tests.test_template_create.TestTemplateCreate)
When rendering GreenPlum 5.3 template, when no distribution is present,
when no primary key is present, it returns "DISTRIBUTED RANDOMLY"
--
Traceback (most recent call last):
  File
"C:\Projects\pgadmin4\web\pgadmin\browser\server_groups\servers\databases\schemas\tables\tests\test_template_create.py",
line 99, in runTest
self.template_path, **self.input_parameters)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 133, in render_template
return
_render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 830, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 791, in get_template
return self._load_template(name, self.make_globals(globals))
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 765, in _load_template
template = self.loader.load(self, name, globals)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\loaders.py",
line 113, in load
source, filename, uptodate = self.get_source(environment, name)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 57, in get_source
return self._get_source_fast(environment, template)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 85, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: table\sql\gpdb_5.0_plus\create.sql

==
ERROR: runTest
(pgadmin.browser.server_groups.servers.databases.schemas.tables.tests.test_template_create.TestTemplateCreate)
When rendering GreenPlum 5.3 template, when no distribution is present,
when primary key is present, it returns "DISTRIBUTED BY (attr_primary_key)"
--
Traceback (most recent call last):
  File
"C:\Projects\pgadmin4\web\pgadmin\browser\server_groups\servers\databases\schemas\tables\tests\test_template_create.py",
line 99, in runTest
self.template_path, **self.input_parameters)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 133, in render_template
return
_render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 830, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 791, in get_template
return self._load_template(name, self.make_globals(globals))
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 765, in _load_template
template = self.loader.load(self, name, globals)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\loaders.py",
line 113, in load
source, filename, uptodate = self.get_source(environment, name)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 57, in get_source
return self._get_source_fast(environment, template)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 85, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: table\sql\gpdb_5.0_plus\create.sql

==
ERROR: runTest
(pgadmin.browser.server_groups.servers.databases.schemas.tables.tests.test_template_create.TestTemplateCreate)
When rendering GreenPlum 5.3 template, when distribution is present, it
returns "DISTRIBUTED BY (attr1, attr2, attr4)"
--
Traceback (most recent call last):
  File
"C:\Projects\pgadmin4\web\pgadmin\browser\server_groups\servers\databases\schemas\tables\tests\test_template_create.py",
line 99, in runTest
self.template_path, **self.input_parameters)
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\flask\templating.py",
line 133, in render_template
return
_render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File
"C:\Projects\venv_pgadmin4_py_3_4\lib\site-packages\jinja2\environment.py",
line 830, in get_or_select_template