Re: pgAdmin4 - help adding new node to Browser Tree

2020-09-02 Thread Aditya Toshniwal
Hi Warren,

Can you check the browser console if any errors ? Can you also share the
patch so that I can help you further by debugging at my end ?

On Wed, Sep 2, 2020 at 9:51 AM Warren Chan  wrote:

> Hi,
>
> I'm trying to learn about the pgAdmin4 project and am hoping to make some
> contributions sometime in the future.
>
> I'm new to Flask and python but am keen to learn.
>
> While trying to familiarize myself with the application and the way it
> works, I've tried to create a 'test' node under the schema node, I want to
> list test items under this node - not listing anything particular at the
> moment but wanted to get an understanding of how the application ties
> together). In order to just get a new node added under schema, I've
> copied the sequence folder under
> \web\pgadmin\browser\server_groups\servers\databases\schemas and renamed
> the applicable folders to tests (I want a test node to appear under schema).
>
> I've updated the \tests\_init_.py file so that the SequenceModule has been
> changed to TestModule (updated the NODE_TYPE etc). I've also updated the
> SequenceView to become TestView and other parts of the view like the
> template path etc.
>
> In addition to this I've changed the name in the
> \tests\static\js\sequence.js file to \tests\static\js\test.js and have
> also updated the test.js file so that any references to sequence has been
> changed to test and have added 'pgadmin.node.tests' to the
> webpack.config.js and 'pgadmin.node.test': path.join(__dirname,
> './pgadmin/browser/server_groups/servers/databases/schemas/tests/static/js/test')
> to the webpack.shim.js file
>
> Doing this I was hoping that a new 'Test' node would appear under the
> schema directory and opening this node, would render all the sequences (as
> I haven't changed any of the sql). However I only get the new 'Test' node
> being rendered, and when I open this, I get a Server Node with the server
> I'm connected to being added, not the list of sequences I was hoping for.
>
> Is there an additional setting / steps I need to add somewhere in order to
> get the TestView to render under the TestModule node?
>
> I'd appreciate any pointers to get this working as the next thing I'd
> like, would be to start modifying the sql and getting different database
> objects being listed.
>
> Best regards,
> Warren Chan
>
>
>

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*

"Don't Complain about Heat, Plant a TREE"


pgAdmin 4 commit: Rename the menu option 'Search objects' to 'Search Ob

2020-09-02 Thread Akshay Joshi
Rename the menu option 'Search objects' to 'Search Objects...'

Branch
--
master

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

Modified Files
--
web/pgadmin/tools/search_objects/static/js/search_objects.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgAdmin 4 commit: Added exclamation icon to alertify warning messages.

2020-09-02 Thread Akshay Joshi
Added exclamation icon to alertify warning messages.

Branch
--
master

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

Modified Files
--
web/pgadmin/static/js/alertify.pgadmin.defaults.js | 15 ++-
1 file changed, 14 insertions(+), 1 deletion(-)



pgAdmin 4 commit: Fixed cognitive complexity issues reported by SonarQu

2020-09-02 Thread Akshay Joshi
Fixed cognitive complexity issues reported by SonarQube.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=8f3bdf1cf3180102b81f3400bb3228daf9197bae
Author: Aditya Toshniwal 

Modified Files
--
.../server_groups/servers/pgagent/__init__.py  |  43 ++
.../browser/server_groups/servers/pgagent/utils.py |  38 +
web/pgadmin/utils/driver/psycopg2/__init__.py  |  44 +++---
web/setup.py   | 154 ++---
4 files changed, 148 insertions(+), 131 deletions(-)



Re: [pgAdmin][SonarQube] Reduce cognitive complexity

2020-09-02 Thread Akshay Joshi
Thanks, patch applied.

On Tue, Sep 1, 2020 at 3:34 PM Aditya Toshniwal <
aditya.toshni...@enterprisedb.com> wrote:

> Hi Hackers,
>
> Attached patch reduces cognitive complexity as below:
>
> web/.../server_groups/servers/pgagent/__init__.py - 23 to 15
> web/pgadmin/utils/driver/psycopg2/__init__.py - 23 to 15, 17 to 15
> web/setup.py 77 to 15
>
> Please review.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
> 
> "Don't Complain about Heat, Plant a TREE"
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


Re: pgAdmin4 - help adding new node to Browser Tree

2020-09-02 Thread Aditya Toshniwal
Hi Warren,

The patch works fine, just that replacing sequences with foos was missing
at 1-2 places. I guess you've not restarted the dev server after the
changes. :)
- Always restart the backend dev server if there is any change in Python or
any template files.
- You can run webpack in continuous watch mode with yarn run bundle:dev
--watch. Always empty cache reload if there is any change in JS files. You
can enable chrome dev tools and right click on the refresh button to get
the option.

Here's what I've changed in your patch:

*diff --git
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py*

*index 3bc310d6f..52de71f0b 100644*

*---
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py*

*+++
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py*

@@ -141,7 +141,7 @@ class FooView(PGChildNodeView, SchemaDiffObjectCompare):

 if self.manager.db_info is not None and \

 kwargs['did'] in self.manager.db_info else 0



-self.template_path = 'sequences/sql/#{0}#'.format(

+self.template_path = 'foos/sql/#{0}#'.format(

 self.manager.version

 )

 self.acl = ['r', 'w', 'U']

*diff --git
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql*

*index cd9b0154a..91a2f9259 100644*

*---
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql*

*+++
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql*

@@ -4,4 +4,4 @@ SELECT

 FROM

 pg_statio_all_sequences

 WHERE

-relid = {{ seid }}::OID

\ No newline at end of file

+relid = {{ fooid }}::OID


On Thu, Sep 3, 2020 at 8:29 AM Warren Chan  wrote:

> Hi Aditya,
>
> thanks for helping, really appreciate you taking the time.
>
> I've attached a patch as requested and yes, when i expand the new Foo node
> I've created, I get the following errors in the console:
>
> 2020-09-03 12:50:37,291: ERROR  flask.app:  404 Not Found: The
> requested URL was not found on the server. If you entered the URL manually
> please check your spelling and try again.
> Traceback (most recent call last):
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1813, in full_dispatch_request
> rv = self.dispatch_request()
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1791, in dispatch_request
> self.raise_routing_exception(req)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1774, in raise_routing_exception
> raise request.routing_exception
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line
> 336, in match_request
> self.url_adapter.match(return_rule=True)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py",
> line 1945, in match
> raise NotFound()
> werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not
> found on the server. If you entered the URL manually please check your
> spelling and try again.
> 2020-09-03 12:50:37,372: ERROR  flask.app:  404 Not Found: The
> requested URL was not found on the server. If you entered the URL manually
> please check your spelling and try again.
> Traceback (most recent call last):
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1813, in full_dispatch_request
> rv = self.dispatch_request()
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1791, in dispatch_request
> self.raise_routing_exception(req)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1774, in raise_routing_exception
> raise request.routing_exception
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line
> 336, in match_request
> self.url_adapter.match(return_rule=True)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py",
> line 1945, in match
> raise NotFound()
> werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not
> found on the server. If you entered the URL manually please check your
> spelling and try again.
>
> Please let me know if you need anything else.
>
> Best Regards,
> Warren Chan
> On Wednesday, 2 September 2020, 6:19:59 pm AEST, Aditya Toshniwal <
> aditya.toshni...@enterprisedb.com> wrote:
>
>
> Hi Warren,
>
> Can you check the browser console if any errors ? Can you also share the
> patch so that I can help you further by debugging at my end ?
>
> On Wed, Sep 2, 2020 at 9:51 AM Warren Chan  wrote:
>
> Hi,
>
> I'm trying to learn about the pgAdmin4 project and am hoping to make some
> contributions sometime in the future.
>
>

Re: pgAdmin4 - help adding new node to Browser Tree

2020-09-02 Thread Warren Chan
 Hi Aditya,
thats it, I wasn't running yarn bundle after my modifications to the templates. 
Thanks for tip to run webpack in continuous mode, that's great.

Really appreciate the help in getting past this. 

Best Regards,Warren Chan

On Thursday, 3 September 2020, 2:43:56 pm AEST, Aditya Toshniwal 
 wrote:  
 
 Hi Warren,
The patch works fine, just that replacing sequences with foos was missing at 
1-2 places. I guess you've not restarted the dev server after the changes. :)- 
Always restart the backend dev server if there is any change in Python or any 
template files.- You can run webpack in continuous watch mode with yarn run 
bundle:dev --watch. Always empty cache reload if there is any change in JS 
files. You can enable chrome dev tools and right click on the refresh button to 
get the option.
Here's what I've changed in your patch:
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py

index 3bc310d6f..52de71f0b 100644

--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py

+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py

@@ -141,7 +141,7 @@ class FooView(PGChildNodeView, SchemaDiffObjectCompare):

                     if self.manager.db_info is not None and \

                     kwargs['did'] in self.manager.db_info else 0

 

-                self.template_path = 'sequences/sql/#{0}#'.format(

+                self.template_path = 'foos/sql/#{0}#'.format(

                     self.manager.version

                 )

                 self.acl = ['r', 'w', 'U']

diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql

index cd9b0154a..91a2f9259 100644

--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql

+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql

@@ -4,4 +4,4 @@ SELECT

 FROM

     pg_statio_all_sequences

 WHERE

-    relid = {{ seid }}::OID

\ No newline at end of file

+    relid = {{ fooid }}::OID


On Thu, Sep 3, 2020 at 8:29 AM Warren Chan  wrote:

 Hi Aditya,
thanks for helping, really appreciate you taking the time.
I've attached a patch as requested and yes, when i expand the new Foo node I've 
created, I get the following errors in the console:

2020-09-03 12:50:37,291: ERROR  flask.app:  404 Not Found: The requested 
URL was not found on the server. If you entered the URL manually please check 
your spelling and try again.
Traceback (most recent call last):
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1813, in 
full_dispatch_request
    rv = self.dispatch_request()
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1791, in 
dispatch_request
    self.raise_routing_exception(req)
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1774, in 
raise_routing_exception
    raise request.routing_exception
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line 336, in 
match_request
    self.url_adapter.match(return_rule=True)
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py", line 
1945, in match
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on 
the server. If you entered the URL manually please check your spelling and try 
again.
2020-09-03 12:50:37,372: ERROR  flask.app:  404 Not Found: The requested 
URL was not found on the server. If you entered the URL manually please check 
your spelling and try again.
Traceback (most recent call last):
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1813, in 
full_dispatch_request
    rv = self.dispatch_request()
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1791, in 
dispatch_request
    self.raise_routing_exception(req)
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1774, in 
raise_routing_exception
    raise request.routing_exception
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line 336, in 
match_request
    self.url_adapter.match(return_rule=True)
  File "C:\git\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py", line 
1945, in match
    raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on 
the server. If you entered the URL manually please check your spelling and try 
again.
Please let me know if you need anything else.
Best Regards,Warren Chan
   On Wednesday, 2 September 2020, 6:19:59 pm AEST, Aditya Toshniwal 
 wrote:  
 
 Hi Warren,
Can you check the browser console if any errors ? Can you also share the patch 
so that I can help you further by debugging at my end ?
On We

Re: pgAdmin4 - help adding new node to Browser Tree

2020-09-02 Thread Aditya Toshniwal
Hi Warren,

On Thu, Sep 3, 2020 at 11:14 AM Warren Chan  wrote:

> Hi Aditya,
>
> thats it, I wasn't running yarn bundle after my modifications to the
> templates. Thanks for tip to run webpack in continuous mode, that's great.
>
You need to restart the backend server if you change the templates. yarn
bundle is needed when JS files are changed.
Glad it worked :)

>
> Really appreciate the help in getting past this.
>
> Best Regards,
> Warren Chan
>
> On Thursday, 3 September 2020, 2:43:56 pm AEST, Aditya Toshniwal <
> aditya.toshni...@enterprisedb.com> wrote:
>
>
> Hi Warren,
>
> The patch works fine, just that replacing sequences with foos was missing
> at 1-2 places. I guess you've not restarted the dev server after the
> changes. :)
> - Always restart the backend dev server if there is any change in Python
> or any template files.
> - You can run webpack in continuous watch mode with yarn run bundle:dev
> --watch. Always empty cache reload if there is any change in JS files. You
> can enable chrome dev tools and right click on the refresh button to get
> the option.
>
> Here's what I've changed in your patch:
>
> *diff --git
> a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py
> b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py*
>
> *index 3bc310d6f..52de71f0b 100644*
>
> *---
> a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py*
>
> *+++
> b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/__init__.py*
>
> @@ -141,7 +141,7 @@ class FooView(PGChildNodeView,
> SchemaDiffObjectCompare):
>
>  if self.manager.db_info is not None and \
>
>  kwargs['did'] in self.manager.db_info else 0
>
>
>
> -self.template_path = 'sequences/sql/#{0}#'.format(
>
> +self.template_path = 'foos/sql/#{0}#'.format(
>
>  self.manager.version
>
>  )
>
>  self.acl = ['r', 'w', 'U']
>
> *diff --git
> a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql
> b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql*
>
> *index cd9b0154a..91a2f9259 100644*
>
> *---
> a/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql*
>
> *+++
> b/web/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql*
>
> @@ -4,4 +4,4 @@ SELECT
>
>  FROM
>
>  pg_statio_all_sequences
>
>  WHERE
>
> -relid = {{ seid }}::OID
>
> \ No newline at end of file
>
> +relid = {{ fooid }}::OID
>
>
> On Thu, Sep 3, 2020 at 8:29 AM Warren Chan  wrote:
>
> Hi Aditya,
>
> thanks for helping, really appreciate you taking the time.
>
> I've attached a patch as requested and yes, when i expand the new Foo node
> I've created, I get the following errors in the console:
>
> 2020-09-03 12:50:37,291: ERROR  flask.app:  404 Not Found: The
> requested URL was not found on the server. If you entered the URL manually
> please check your spelling and try again.
> Traceback (most recent call last):
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1813, in full_dispatch_request
> rv = self.dispatch_request()
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1791, in dispatch_request
> self.raise_routing_exception(req)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1774, in raise_routing_exception
> raise request.routing_exception
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line
> 336, in match_request
> self.url_adapter.match(return_rule=True)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py",
> line 1945, in match
> raise NotFound()
> werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not
> found on the server. If you entered the URL manually please check your
> spelling and try again.
> 2020-09-03 12:50:37,372: ERROR  flask.app:  404 Not Found: The
> requested URL was not found on the server. If you entered the URL manually
> please check your spelling and try again.
> Traceback (most recent call last):
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1813, in full_dispatch_request
> rv = self.dispatch_request()
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1791, in dispatch_request
> self.raise_routing_exception(req)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line
> 1774, in raise_routing_exception
> raise request.routing_exception
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line
> 336, in match_request
> self.url_adapter.match(return_rule=True)
>   File "C:\git\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py",
> line 1945, in match
> raise NotFound()
> werkzeug.exceptions.