Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1et9Dr-0006IA-1C for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Mar 2018 09:49:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1et9Dp-0004sQ-5S for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Mar 2018 09:49:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1et9Do-0004ry-IU for pgadmin-hackers@lists.postgresql.org; Tue, 06 Mar 2018 09:49:25 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1et9Dk-0002k4-QZ for pgadmin-hackers@postgresql.org; Tue, 06 Mar 2018 09:49:23 +0000 Received: by mail-wr0-x244.google.com with SMTP id k9so20197215wre.9 for ; Tue, 06 Mar 2018 01:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pWHQPDSDwNRngwJI5h944MDdrlyosxzL/tiE2lqAN9Q=; b=rVn7QKCjzbayZwulEisYacdJ8sqoEeofm99UILZLKuaPP06gT8T7bBpRK1icb1V2Wk TsuomNYLOIfpMUKyHxOqukkyPYYCcWh8weaapRePf1sDR466lU9rN6J2sZ+8i2xJXRpz Lp6JZIvpQaEnSKz7shxIhOdAcvmFBKTyM6+MAu/07LpfoyLxyRX/XCh21+4/XUkUS2ZL ESZRKbHRUQJvFMZQ0eX5SWSLokmrX1yb/9LkOW7Ishw7HuXrP5RUOZ6JzM3xS9WCFzz+ buY7o7wAQHeVeficC1+N7G/3o6WmAvQwQfSDLWHYjGSha0PxDkOpWZ3KAOTVaM2kwoSS 9LNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pWHQPDSDwNRngwJI5h944MDdrlyosxzL/tiE2lqAN9Q=; b=YFhDouMnTnnN2iAyOp0ABjcC+czw8Z9l7nsMVWJp0L6rDZ8hl75GfzwTQG3DZBLDaa yyeAFzvzC1evevj3CGVpotMbrj2jaGMfJC0N/ZzGmpVV2YdywmMCjRl4u2E/JHH3H3w5 y+fwwT1GWGVd7QgskHvMffjHxNAZhICzErBOjtT9hVONXKNAURL7hZQA/EXGcBMMx9xv PmjS/GtgeAGON9567AvDNOwcknBZtzqUMFA9JdylMIU+Rurj8f9kpf23ka/j4VKmGdzE WP3//4gLaT0OGepQf8ABprmwBLy7rrM8+VXL/Gi59PDuylOfD14EoI/wC+m6A1LXOqBH JrrA== X-Gm-Message-State: APf1xPAEeTWIvIdoMDrenj2DXaDxQIHO09XtrWkwrMSLzeEIgYBU8o64 KGpRnOZlhEH4UVWnebYofBEl73cd2AroxOtQ+iF5SQ== X-Google-Smtp-Source: AG47ELsA1Z5Y9oioBuuCNs8LbQjyglw0+KLAydREn3NLgiaJMaaCPyEsuo6zRAviq2fbrHz0SUXznSVsQ5MVC6RsPdY= X-Received: by 10.223.153.215 with SMTP id y81mr15184246wrb.144.1520329759205; Tue, 06 Mar 2018 01:49:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.109.7 with HTTP; Tue, 6 Mar 2018 01:49:18 -0800 (PST) In-Reply-To: References: From: Dave Page Date: Tue, 6 Mar 2018 09:49:18 +0000 Message-ID: Subject: Re: [pgAdmin4][RM#3037] Allow user to disable Gravatar image To: Murtuza Zabuawala Cc: Joao De Almeida Pereira , pgadmin-hackers Content-Type: multipart/alternative; boundary="f403045ce2ea3d3c390566bb5b8d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --f403045ce2ea3d3c390566bb5b8d Content-Type: text/plain; charset="UTF-8" Hi On Tue, Mar 6, 2018 at 6:59 AM, Murtuza Zabuawala < murtuza.zabuawala@enterprisedb.com> wrote: > 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. > For this particular issue, I'm inclined to agree. I do however, like the idea of caching preferences (no-brainer really, assuming we ensure we update/invalidate the cache when needed), and using promises for accessing them. > > 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 < > jdealmeidapereira@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.zabuawala@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 < >>> jdealmeidapereira@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.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 >>>>> >>>>> >>> > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company --f403045ce2ea3d3c390566bb5b8d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Tue, Mar 6, 2018 at 6:59 AM, Murtuza Zabuawala &= lt;= murtuza.zabuawala@enterprisedb.com> wrote:
Hi Joao,

Your suggestion is good but in my own opinion it is o= verkill just to replace code=C2=A0{{ usern= ame| gravatar }}=C2=A0as rest of the syn= tax=C2=A0is pure HTML, This makes code much simpler and easy to understand<= /font>.
Apart from that we will be rendering 'index.html' templat= e anyways and I don't see any extra overhead.
<= div>
For this particular issue, I'm inclined to agree.

I do however, like the idea of caching preferences (= no-brainer really, assuming we ensure we update/invalidate the cache when n= eeded), and using promises for accessing them.
=C2=A0

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

Regards,=C2=A0
<= font color=3D"#888888">
Murtuza

On Tue, Mar 6, 2018 at 1:17 AM, Joao De Alme= ida Pereira <jdealmeidapereira@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.=C2=A0
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:
=C2=A0- Add gravata= r library to package.json
=C2=A0- Created a Preferences cache. (j= s/preferences.js)
=C2=A0 =C2=A0- So this was the concept I was ta= lking about in a previous email we talked about caching.
=C2=A0 = =C2=A0 =C2=A0 the getConfiguration and the getAllConfiguration are not grea= t names, but they return a Promise that is consumed in the load_gravatar. T= he idea here is that we are caching the pgAdmin settings and when need need= to consume them, we wait for it to be available.
=C2=A0- load_gr= avatar is using the pattern to retrieve the configuration from a possible c= ache and then apply the gravatar


Th= ings 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 hardcod= ed to get the configuration
- Maybe the Preferences is not the co= rrect 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.zabuawala@enterprisedb.com> w= rote:
= Hi Joao,

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

--
Regards,
Murtuza Zabuawala
Enterprise= DB:=C2=A0http://www.enterprisedb.com
The Enterprise PostgreS= QL Company


On Mon, Mar= 5, 2018 at 8:57 PM, Joao De Almeida Pereira <jdealmeidapereir= a@pivotal.io> wrote:
Hi Murtuza,

Why are we doi= ng 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 s= tatic image if not?

+
+{% if config= .SERVER_MODE %}
=C2=A0window.onload =3D function(e){
= =C2=A0 setTimeout(function() {
-=C2=A0 =C2=A0var gravatarImg =3D = '<img src=3D"{{ username | gravatar }}" width=3D"18&q= uot; height=3D"18" alt=3D"Gravatar image for {{ username }}&= quot;> {{ username }} <span class=3D"caret"></span>= ;';
+=C2=A0 =C2=A0var gravatarImg =3D {{ IMG.PREPARE_HTML()|s= afe }}
=C2=A0 =C2=A0 //$('#navbar-menu .navbar-right > li = > a').html(gravatarImg);
=C2=A0 =C2=A0 var navbarRight =3D= document.getElementById("navbar-menu").getElementsByClassNa= me("navbar-right")[0];
=C2=A0 =C2=A0 if (navbarRig= ht) {

what if we have=C2=A0

var gravatarImg =3D '<img src=3D"/user/{{username}}/gr= avatar" width=3D"18" height=3D"18" alt=3D&quo= t;Gravatar image for {{ username }}"> {{ username }} <span class= =3D"caret"></span>';

An= d then the endpoint
/user/{{username}}/gravatar=C2=A0
w= ould be responsible for returning a Gravatar or not depending on the config= uration?


Thanks
Joao

On Mon, Mar 5, 2018 = at 3:13 AM Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com&g= t; wrote:
Hi,

PFA patch to disable Gravatar image in Server mode.

Requirments & Issue= s:
-= For security reasons.
- For syst= ems which do not have internet access.
- Hangs pgAdmin4 while loading = the page if connection has no internet access (as described in the ticket)<= /div>

--
Rega= rds,
Murtuza Zabuawala
EnterpriseDB:=C2=A0http://www.enterprisedb.com
The Enterprise PostgreSQL Company
<= /div>
<= br>





--
Dave Page
Blog: = http://pgsnake.bl= ogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com<= br>The Enterprise PostgreSQL Company
--f403045ce2ea3d3c390566bb5b8d--