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 1kDiKl-00064H-3y for pgadmin-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 06:02:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDiKi-0003G3-CV for pgadmin-hackers@arkaria.postgresql.org; Thu, 03 Sep 2020 06:02:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDiKi-0003Fe-0C for pgadmin-hackers@lists.postgresql.org; Thu, 03 Sep 2020 06:02:52 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kDiKd-0003Cj-MP for pgadmin-hackers@lists.postgresql.org; Thu, 03 Sep 2020 06:02:51 +0000 Received: by mail-ed1-x534.google.com with SMTP id ay8so1397221edb.8 for ; Wed, 02 Sep 2020 23:02: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=Opju8rhGbRUz0lKUL685dRPlKGOr0sg414TXmUQtSyQ=; b=kPYD6L1ul+sKzgqCIeNLIm0MvbEIBq4KPlism3Cg5DXQeTlOhRpK4t+nMVJPctdaeh x4xX7H9Gl0qR0bN9Z/r+EXyV7AxzFyS6FK3JA9pQ4VKX/D9eJ6piwMz43X9BWcJtt9cX ch5XKtS3pxcMbj1cfrBRb+8hvoj0caP6dSgzZ4pRSWf+8SXd5zuFNCOI6CTygUOImsoD rrnAPucoZAd+JLsV3sChLGJgg1TZWMYRQBdQE+s6L7PMT0wHXjK9+i+vqdKIGL7kOwii 8cD5UJIwLB2XPTHEAx88O40CTybMmThJFRZz4VfDIcxb0UJ4Jv1HSxmv7oAH8EIrSOK6 4kBA== 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=Opju8rhGbRUz0lKUL685dRPlKGOr0sg414TXmUQtSyQ=; b=SC3sLHRwY2h2Mg2QTieFzBsO7k28i/qvQX+vfi9XQsgZ/452uQfM5JJx8Md26sRHnX NKik90BFsHdQNP+IVE8ZAnd9w80wA5X/XJcA8ilRbYR0PZK8GTqYSOZMNQMpZiZw5cpt 01wztG3DoqAGjcpsxV9TSoiyJs7UJZws2pMPsFsUiZEBlz4O54n62F9GWwPW41WKtMag phrvcNCucpk94valYdXPSmgZrfW4WScCyAD/Y1kn/qun0j54Au20T9LYIut1bnaLsPLa 4sqM8JNgMmVr02goxCJ8jiTZSFz6NU0Ikbsd5pM72RsUgR2g3P8B6fhX2zk+ZQx4wMvu Pp8w== X-Gm-Message-State: AOAM531CtNJqCEw1sPvWsXzXpl4gkd9BQKI0gHFLpKRQ8fP7MSyeqRH3 H819/JVbJQyN1pTnR23rmBhgO2lfsKv993NmjwZWF54e+Ze0wJ3kl/cwX3WMfN0Rhiw/op8mWP6 xAGekWJJsaiOEvT292fwCeR5en8xXeUqBVyoMXo4LGEVNwM6Dfs/xW4bZW+dTilxxKeE9XK1JDk 9nFgSjmPqJBDHC7Bt415t2U+hlVW9PgfR6/BFu7+HrW716KBDcy9jLRto0wGw5/VBo47ZJcZZBw XpusUgKgw== X-Google-Smtp-Source: ABdhPJyyqTUt7nRnf2PzEYQh/GlHQyKjBEHGPcsMaVjgzdvzEVaRj/A91U+s1t808QTcnNLAZjxmZD+NBcEPHYByU7Y= X-Received: by 2002:aa7:cc14:: with SMTP id q20mr1364234edt.309.1599112965012; Wed, 02 Sep 2020 23:02:45 -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> <1472932300.1849038.1599111865981@mail.yahoo.com> In-Reply-To: <1472932300.1849038.1599111865981@mail.yahoo.com> From: Aditya Toshniwal Date: Thu, 3 Sep 2020 11:32:08 +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="0000000000003c601105ae6280c2" 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 --0000000000003c601105ae6280c2 Content-Type: text/plain; charset="UTF-8" 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.toshniwal@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.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" > -- Thanks, Aditya Toshniwal pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* "Don't Complain about Heat, Plant a TREE" --0000000000003c601105ae6280c2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Warren,

On Thu, Sep 3, 2020 at 11:14 A= M Warren Chan <wchan_syd@yahoo= .com.au> 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&#= 39;s great.
You need to restart the back= end server if you change the templates. yarn bundle is needed when JS files= are changed.
Glad it worked :)=C2=A0

Really appreciate t= he help in getting past this.

Best Regards,
Warren Chan

=
=20
=20
On Thursday, 3 September 2020, 2:43:56 pm AEST, Aditya = Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:


<= div>
Hi Warre= n,

The patch works fine, jus= t that replacing sequences with foos=C2=A0was missing at 1-2 places. I gues= s you've not=C2=A0restarted the dev server after the changes. :)
<= div style=3D"font-family:verdana,sans-serif">- Always restart the backend d= ev server if there is any change in Python or any template files.
- You can run webpack in continuo= us watch mode with yarn run bundle:dev --watch. Always empty cache reload i= f there is any change in JS files. You can enable chrome dev tools and righ= t click on the refresh button to get the option.

Here's what I've changed in your patch:
<= div style=3D"font-family:verdana,sans-serif">

diff --git a/web/pgadmin/browser/server_gro= ups/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/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 N= one 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.ma= nager.db_info else 0

=C2=A0

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

+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 self.template_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.acl =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 {{ s= eid }}::OID

\ No newline at end of file

+=C2=A0 =C2=A0 relid =3D {{ f= ooid }}::OID

=

On Thu, Sep 3, 20= 20 at 8:29 AM Warren Chan <wchan_syd@yahoo.com.au&g= t; wrote:
Hi Aditya,

thanks for helping, really appreciate you taking t= he time.

I&= #39;ve attached a patch as requested and yes, when i expand the new Foo nod= e I've created, I get the following errors in the console:

2020-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 entered the URL manu= ally please check your spelling and try again.
Traceback = (most recent call last):
=C2=A0 File "C:\git\pgadmin= 4\pgadmin4\lib\site-packages\flask\app.py", line 1813, in full_dispatc= h_request
=C2=A0=C2=A0=C2=A0 rv =3D self.dispatch_request= ()
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\site-pa= ckages\flask\app.py", line 1791, in dispatch_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 request.routing_exception
=C2=A0 File "C:\= git\pgadmin4\pgadmin4\lib\site-packages\flask\ctx.py", line 336, in ma= tch_request
=C2=A0=C2=A0=C2=A0 self.url_adapter.match(ret= urn_rule=3DTrue)
=C2=A0 File "C:\git\pgadmin4\pgadmi= n4\lib\site-packages\werkzeug\routing.py", line 1945, in match
=C2=A0=C2=A0=C2=A0 raise NotFound()
werkzeug.e= xceptions.NotFound: 404 Not Found: The requested URL was not found on the s= erver. If you entered the URL manually please check your spelling and try a= gain.
2020-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 entered the URL manually please check your spelling a= nd try again.
Traceback (most recent call last):
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\site-packages\flas= k\app.py", line 1813, in full_dispatch_request
=C2= =A0=C2=A0=C2=A0 rv =3D self.dispatch_request()
=C2=A0 Fil= e "C:\git\pgadmin4\pgadmin4\lib\site-packages\flask\app.py", line= 1791, in dispatch_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 request.routing_except= ion
=C2=A0 File "C:\git\pgadmin4\pgadmin4\lib\site-p= ackages\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, in match
=C2=A0=C2=A0=C2=A0 = raise NotFound()
werkzeug.exceptions.NotFound: 404 Not Fo= und: 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
=20
On Wednesday, 2 September 2020, 6:19:59 pm AEST, Aditya= Toshniwal <aditya.toshniwal@enterprisedb.co= m> wrote:


Hi Warren,

Can you check the browser console if any errors ? Can you a= lso 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 <wchan_= syd@yahoo.com.au> wrote:
Hi,

I'm trying to learn about the pgAdmi= n4 project and am hoping to make some contributions sometime in the future.=

I'm ne= w to Flask and python but am keen to learn.

While trying to familiarize myself with th= e application and the way it works, I've tried to create a 'test= 9; 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 understa= nding of how the application ties together). In order to just get a new nod= e 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"


--
<= div dir=3D"ltr">
Thanks,= Aditya = Toshniwal
pgAdmin hacker=C2=A0|= Sr. S= oftware Engineer | edbpostgres.com
"Don't C= omplain 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"
--0000000000003c601105ae6280c2--