Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDh6I-0002BI-5x for pgadmin-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 04:43:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDh6G-00006l-9N for pgadmin-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 04:43:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDh6F-0008WC-Pr for pgadmin-hackers@lists.postgresql.org; Thu, 03 Sep 2020 04:43:52 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDh6C-0003KS-1n for pgadmin-hackers@lists.postgresql.org; Thu, 03 Sep 2020 04:43:50 +0000 Received: by mail-ed1-x533.google.com with SMTP id g4so1298541edk.0 for ; Wed, 02 Sep 2020 21:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lVNNi5rstKgyjO8dmnwPPxoSUKAvcTFvOx4EVFyCHWM=; b=ZeTy+M0PUjYfCwKJvQgzxtk5BtFvR+G1l6kiErBC++8XaqHq+1TvM6xvMdTm549QzB wiCyJzqpyn9sQMuPqv7Ch9FSyDaEEGHBEIiwYTRuyG0rjA6e+2XRQbYpY3HX4UTyle8R 4n/A4Gj6dXalUZmOGYcsXvLNo9OQgWnSiNIqr86N/Cpf13KBmKWH4Qc+SenRCeMuTJ22 iy7y1gKpmicl0WIa5plv0gNlrJ8OJzvHaptmG8ZIAkMIpdpvDX0tzIY6rK33GXmYxKmf X3qnQQR5UIUnXu4bP3bklTg7kEMGHLoncHL3UdmzTSFWLEoSJWTYdrI0ju0j8pDbAETT aBuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lVNNi5rstKgyjO8dmnwPPxoSUKAvcTFvOx4EVFyCHWM=; b=LTAz1c5IR7RoonTu8Hcy/Bo0w2UioWFwOq+IraIrvi9ik5kIOapQB8YsaGg4mFtIBx FU84dMIC5DHX6S3jZC5z45KlV7qi7310mndJSvcnJNbpskm+833OQBi1XWpC/vFp9RpL 2Oa4tObnKWR8Mz57ne3C9ehASe1JgG7mDmqNp/iY/+F1qh7CCOs4lKLzTbEIyiGkyT8B trTH8XGhNNZhJZ5nio4kqWwPYWkpVp0rlNqWF5sAK4Mzkt0h+N0VsREZcRwZqRIjCm4l GA6ATWx/RogGO2KkkCUiUQyP16FCKTJIdwB8lOf3fzi+mLcdJAvdzbA/JjCjmGM4nIxn lLMQ== X-Gm-Message-State: AOAM531uhlh4Rfbx0u19nWpWpOjUgmhefTd3ATCUJ9rD2pPEkUuLU8x2 d8KvgfLQoxAghfoUSG8+m1+l4qS1UXARYUhVqPNq0R0nFL1a/4sXnE3Z0FyJytlQk2F2u21jDxy V1LBZnb1i3BZprd3MSt2/Ty/LAkBJgZnfC7OTJsAX2Imnp2P60SFhrChlWH6m4n4XrUmn8CaE2S 4TXmu2KCDRsWLy9eCnN3xoO/yDRap0jBNRL+uUgNuNreQ4Ba1KSAnGWOLMAe26b6TCMzVN/GJmT A== X-Google-Smtp-Source: ABdhPJyAAMnbWKnjWI/SYO7PjerbX0A+obR1LFuI0w+eBQ1QMB1TH/Mr1/yVc6iaNpZ9u9dLh8YO4BUdMjyEzudfqbg= X-Received: by 2002:a05:6402:1016:: with SMTP id c22mr1243956edu.89.1599108226290; Wed, 02 Sep 2020 21:43:46 -0700 (PDT) MIME-Version: 1.0 References: <1872014587.1397537.1599020446172.ref@mail.yahoo.com> <1872014587.1397537.1599020446172@mail.yahoo.com> <1679514114.1817148.1599101971834@mail.yahoo.com> In-Reply-To: <1679514114.1817148.1599101971834@mail.yahoo.com> From: Aditya Toshniwal Date: Thu, 3 Sep 2020 10:13:09 +0530 Message-ID: Subject: Re: pgAdmin4 - help adding new node to Browser Tree To: Warren Chan Cc: "pgadmin-hackers@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000c9307b05ae616504" X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000c9307b05ae616504 Content-Type: text/plain; charset="UTF-8" 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.toshniwal@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. > > 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" > -- Thanks, Aditya Toshniwal pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* "Don't Complain about Heat, Plant a TREE" --000000000000c9307b05ae616504 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Warren,

The patch works fine, just that replacing seque= nces with foos=C2=A0was missing at 1-2 places. I guess you've not=C2=A0= 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 c= an run webpack in continuous watch mode with yarn run bundle:dev --watch. A= lways 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.<= /div>
=
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/bro= wser/server_groups/servers/databases/schemas/foos/__init__.py

index 3bc310d6f..52de71f0b 100644

--- a/web/pgadmin/browser/server_groups/ser= vers/databases/schemas/foos/__init__.py

+++ b/web/pgadmin/browser/server_groups/ser= vers/databases/schemas/foos/__init__.py

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

= =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= if self.manager.db_info is not None and \

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

=C2=A0

-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.temp= late_path =3D 'sequences/sql/#{0}#'.format(

+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.temp= late_path =3D 'foos/sql/#{0}#'.format(

= =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= self.manager.version

= =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )

= =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.a= cl =3D ['r', 'w', 'U']

diff --git a/web/pgadmin/browser/server_gro= ups/servers/databases/schemas/foos/templates/foos/sql/default/stats.sql b/w= eb/pgadmin/browser/server_groups/servers/databases/schemas/foos/templates/f= oos/sql/default/stats.sql

index cd9b0154a..91a2f9259 100644

--- a/web/pgadmin/browser/server_groups/ser= vers/databases/schemas/foos/templates/foos/sql/default/stats.sql=

+++ b/web/pgadmin/browser/server_groups/ser= vers/databases/schemas/foos/templates/foos/sql/default/stats.sql=

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

= =C2=A0FROM

= =C2=A0=C2=A0 =C2=A0 pg_statio_all_sequences

= =C2=A0WHERE

-=C2=A0 =C2=A0 relid =3D {{ seid }}::OID

\ No newline at end of file

+=C2=A0 =C2=A0 relid =3D {{ fooid }}::OID


On Thu, Sep 3, 2020 at 8:29 AM Warren Chan <wchan_syd@yahoo.com.au> wrote:
=
Hi Aditya,

thanks for helping, really appreciate you taking the time.
<= div dir=3D"ltr">
I've attached a patch as req= uested and yes, when i expand the new Foo node I've created, I get the = following errors in the console:

20= 20-09-03 12:50:37,291: ERROR=C2=A0 flask.app:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= 404 Not Found: The requested URL was not found on the server. If you enter= ed the URL manually please check your spelling and try again.
Traceback = (most recent call last):
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\= site-packages\flask\app.py", line 1813, in full_dispatch_request
= =C2=A0=C2=A0=C2=A0 rv =3D self.dispatch_request()
=C2=A0 File "C:\g= it\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1791, in di= spatch_request
=C2=A0=C2=A0=C2=A0 self.raise_routing_exception(req)
= =C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py&q= uot;, line 1774, in raise_routing_exception
=C2=A0=C2=A0=C2=A0 raise req= uest.routing_exception
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\si= te-packages\flask\ctx.py", line 336, in match_request
=C2=A0=C2=A0= =C2=A0 self.url_adapter.match(return_rule=3DTrue)
=C2=A0 File "C:\g= it\pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py", line 1945= , in match
=C2=A0=C2=A0=C2=A0 raise NotFound()
werkzeug.exceptions.No= tFound: 404 Not Found: The requested URL was not found on the server. If yo= u entered the URL manually please check your spelling and try again.
202= 0-09-03 12:50:37,372: ERROR=C2=A0 flask.app:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = 404 Not Found: The requested URL was not found on the server. If you entere= d the URL manually please check your spelling and try again.
Traceback (= most recent call last):
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\s= ite-packages\flask\app.py", line 1813, in full_dispatch_request
=C2= =A0=C2=A0=C2=A0 rv =3D self.dispatch_request()
=C2=A0 File "C:\git\= pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line 1791, in dispa= tch_request
=C2=A0=C2=A0=C2=A0 self.raise_routing_exception(req)
=C2= =A0 File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py"= ;, line 1774, in raise_routing_exception
=C2=A0=C2=A0=C2=A0 raise reques= t.routing_exception
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\site-= packages\flask\ctx.py", line 336, in match_request
=C2=A0=C2=A0=C2= =A0 self.url_adapter.match(return_rule=3DTrue)
=C2=A0 File "C:\git\= pgadmin4\pgadmin4\lib\site-packages\werkzeug\routing.py", line 1945, i= n match
=C2=A0=C2=A0=C2=A0 raise NotFound()
werkzeug.exceptions.NotFo= und: 404 Not Found: The requested URL was not found on the server. If you e= ntered the URL manually please check your spelling and try again.

Please let me know if you need anything else.

Best Regards,
Warren Chan
=20
On Wednesday, 2 September 2020, 6:19:59 pm AEST, Aditya= Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:


=
Hi Warr= en,

<= /div>
Can you check the browse= r console if any errors ? Can you also share the patch so that I can help y= ou further by debugging at my end ?

On Wed, Sep 2, 2020 at 9:51 AM Warren Chan <wchan_sy= d@yahoo.com.au> wrote:
Hi,

I'm t= rying to learn about the pgAdmin4 project and am hoping to make some contri= butions sometime in the future.

I'm new to Flask and python but am keen to learn.<= /div>

While tryin= g 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 lis= t test items under this node - not listing anything particular at the momen= t 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=20 \web\pgadmin\browser\server_groups\servers\databases\schemas and=20 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 e= tc). I've also updated the SequenceView to become TestView and other pa= rts of the view like the template path etc.

In addition to this I've changed the name in the \tests\static\js\s= equence.js file to \tests\static\js\test.js and have also updat= ed 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 a= nd 'pgadmin.node.test': path.join(__dirname, './pgadmin/b= rowser/server_groups/servers/databases/schemas/tests/static/js/test') t= o the webpack.shim.js file

Doing this I was hoping that a= new 'Test' node would appear under the schema directory and openin= g this node, would render all the sequences (as I haven't changed any o= f 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.
<= span>
= Is there an additional setting / steps I need to ad= d somewhere in order to get the TestView to render under the TestModule nod= e?

<= div dir=3D"ltr">I'd appreciate any pointers to = get this working as the next thing I'd like, would be to start modifyin= g the sql and getting different database objects being listed.

= Best regards,
Warren Chan



--
Thanks,
Aditya Toshniwal
=
pgAdmin hacker=C2=A0| Sr. Software Engineer | edbpostgres.com=
"Don't Complain about Heat, Plant a TREE"


-- =
Thanks,
Aditya Toshniwal
pgAdmin hacker= =C2=A0| Sr. Software Engineer | = edbpostgres.com
"Don't Complain about Hea= t, Plant a TREE"
--000000000000c9307b05ae616504--