Re: Custom layers in PgAdmin IV Mapview

From: Dave Page <dpage(at)pgadmin(dot)org>
To: Atle Frenvik Sveen <atle(at)frenviksveen(dot)net>
Cc: pgadmin-hackers <pgadmin-hackers(at)lists(dot)postgresql(dot)org>, Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com>
Subject: Re: Custom layers in PgAdmin IV Mapview
Date: 2018-09-13 14:40:44
Message-ID: CA+OCxowONb1iWT2xL3qHRxzptj_EoUe8j2tfuoOZ=aDgT71vHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi

On Thu, Sep 13, 2018 at 2:50 PM, Atle Frenvik Sveen <atle(at)frenviksveen(dot)net>
wrote:

> Hi list!
>
> The new Mapview is great, but when you give people something they always
> want more, and so do I.
>
> I want to be able to add custom background layers to the existing list of
> layers.
>
> I'm thinking that the list of layers should be configurable from the
> Preferences -> Sql editor menu (or somewhere in the Preferences)
>
> Then again, given that I know both Js, Leaflet, Backbone, and Python/Flask
> I guess I should contribute the changes myself rather then waiting for
> someone else to do this.
>

Cool :-)

>
> However, I have some questions before I jump right on this task:
>
> First some organizational:
> 1. If I add this, is this something that is welcomed by the project?
>

Yes!

> 2. How do I register a task on https://redmine.postgresql.
> org/projects/pgadmin4/issues
>

Assuming you have a user account on there, there's a "New Issue" button
towards the top right.

> 3. Is it ok to clone the GitHub mirror and submit a PR there?
>

You're welcome to work in a GitHub mirror of course, but please send
patches here - we won't see GitHub PRs as our primary repo is
git.postgresql.org.

>
> Then some tech-related questions:
>
> 1. It seems like window.top.pgAdmin.Browser.get_preferences_for_module is
> used for getting preferences from js, and that the PreferencesModule python
> class is responsible for managing preferences. But where are the default
> preferences listed?
>

You'll find register_preferences functions in some of the Python modules
(e.g. web/pgadmin/dashboard/__init__.py). They tend to have a bunch of
calls in them that look like this:

self.session_stats_refresh = self.dashboard_preference.register(
'dashboards', 'session_stats_refresh',
gettext("Session statistics refresh rate"), 'integer',
1, min_val=1, max_val=999999,
category_label=gettext('Graphs'),
help_str=gettext('The number of seconds between graph samples.')
)

In this case, the 1 on the beginning of the fourth line is the default
value.

> 2. Does the preferences code currently handle editing a list of elements?
> I'm thinking that the preferences pane for map layers should be something
> like this.
>
>
> name | url
> |
> ----------|-----------------------------------------------------------------|
> ------
> streets | https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png | [remove]
> [] | []
> | [add]
>
> 2.1 If it does, where in the code can I find it?
> 2.2 It it doesn't, where in the code can I add it and
> 3. In either case of 2: how do I specify how a preference object for a
> module look like?
>

I don't believe it does at the moment. Khushboo, am I missing something?

The Preferences class is in web/pgadmin/utils/preferences.py.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Khushboo Vashi 2018-09-14 03:24:41 Re: Custom layers in PgAdmin IV Mapview
Previous Message Atle Frenvik Sveen 2018-09-13 13:50:33 Custom layers in PgAdmin IV Mapview