public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pradip Parkale <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM6231]- Add OS, Browser details in pgAdmin About us pop-up
Date: Fri, 21 May 2021 14:22:55 +0530
Message-ID: <CAJ9T6Svgp3gKnyRNjS-XkX69e-kNXUDU1BesV1s=ESgNxp2GAA@mail.gmail.com> (raw)
Hi Hackers,
Please find the attached patch for #6231. I have added OS, NW.js, browser
details, and some server configuration in the About pgAdmin pop-up.
Server configuration won't be visible to the non-admin users in server mode.
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] RM6231.patch (7.1K, 3-RM6231.patch)
download | inline diff:
diff --git a/requirements.txt b/requirements.txt
index 08dc344db..605b335d3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -37,3 +37,4 @@ sshtunnel==0.*
ldap3==2.*
Flask-BabelEx==0.*
gssapi==1.6.*
+httpagentparser==1.9.*
\ No newline at end of file
diff --git a/runtime/package.json b/runtime/package.json
index bdc024b18..82628732d 100644
--- a/runtime/package.json
+++ b/runtime/package.json
@@ -6,6 +6,7 @@
"author": "pgAdmin Development Team (https://www.pgadmin.org/)",
"license": "PostgreSQL",
"chromium-args": "--disable-popup-blocking",
+ "user-agent": "Nwjs:%nwver-%osinfo-%chromium_ver",
"window": {
"width": 440,
"height": 170,
diff --git a/web/pgadmin/about/__init__.py b/web/pgadmin/about/__init__.py
index 94ffefe6e..d40de006a 100644
--- a/web/pgadmin/about/__init__.py
+++ b/web/pgadmin/about/__init__.py
@@ -10,13 +10,15 @@
"""A blueprint module implementing the about box."""
import sys
-from flask import Response, render_template, __version__, url_for
+from flask import Response, render_template, __version__, url_for, request
from flask_babelex import gettext
from flask_security import current_user, login_required
from pgadmin.utils import PgAdminModule
from pgadmin.utils.menu import MenuItem
from pgadmin.utils.constants import MIMETYPE_APP_JS
import config
+import httpagentparser
+from pgadmin.model import User
MODULE_NAME = 'about'
@@ -59,23 +61,74 @@ blueprint = AboutModule(MODULE_NAME, __name__, static_url_path='')
@login_required
def index():
"""Render the about box."""
- info = {
- 'python_version': sys.version,
- 'flask_version': __version__
- }
+ info = {}
+ # Get OS , NW.js, Browser details
+ browser, os_details, nwjs_version = detect_browser(request)
+
+ if nwjs_version:
+ info['nwjs'] = nwjs_version
+
+ info['browser_details'] = browser
+ info['os_details'] = os_details
+ info['config_db'] = config.SQLITE_PATH
+ info['log_file'] = config.LOG_FILE
if config.SERVER_MODE:
info['app_mode'] = gettext('Server')
+ admin = is_admin(current_user.email)
+ info['admin'] = admin
else:
info['app_mode'] = gettext('Desktop')
info['current_user'] = current_user.email
+ settings = ''
+ for setting in dir(config):
+ if not setting.startswith('_') and setting.isupper() and \
+ setting not in ['CSRF_SESSION_KEY',
+ 'SECRET_KEY',
+ 'SECURITY_PASSWORD_SALT',
+ 'SECURITY_PASSWORD_HASH',
+ 'ALLOWED_HOSTS']:
+ settings = settings + '{} = {}\n'.format(setting,
+ getattr(config, setting))
+
+ info['settings'] = settings
+
return render_template(
MODULE_NAME + '/index.html', info=info, _=gettext
)
+def is_admin(load_user):
+ user = User.query.filter_by(email=load_user).first()
+ return user.has_role("Administrator")
+
+
+def detect_browser(request):
+ """This function returns the browser and os details"""
+ nwjs_version = None
+ agent = request.environ.get('HTTP_USER_AGENT')
+
+ if 'Nwjs' in agent:
+ agent = agent.split('-')
+ nwjs_version = agent[0].split(':')[1]
+ browser = agent[2]
+ os_details = agent[1].split('; ')[1]
+
+ else:
+ browser = httpagentparser.detect(agent)
+ os_details = browser['platform']['name'] + ' ' + browser['platform'][
+ 'version']
+ if not browser:
+ browser = agent.split('/')[0]
+ else:
+ browser = browser['browser']['name'] + ' ' + browser['browser'][
+ 'version']
+
+ return browser, os_details, nwjs_version
+
+
@blueprint.route("/about.js")
@login_required
def script():
diff --git a/web/pgadmin/about/static/js/about.js b/web/pgadmin/about/static/js/about.js
index c6c73e6c2..a1e45bdba 100644
--- a/web/pgadmin/about/static/js/about.js
+++ b/web/pgadmin/about/static/js/about.js
@@ -62,7 +62,7 @@ define(
function(data) {
alertify.aboutDialog(
gettext('About %s', pgAdmin.Browser.utils.app_name), data
- ).resizeTo(pgAdmin.Browser.stdW.md, pgAdmin.Browser.stdH.md);
+ ).resizeTo(pgAdmin.Browser.stdW.md, 450);
});
},
};
diff --git a/web/pgadmin/about/templates/about/index.html b/web/pgadmin/about/templates/about/index.html
index 607e6c298..c7c260822 100644
--- a/web/pgadmin/about/templates/about/index.html
+++ b/web/pgadmin/about/templates/about/index.html
@@ -4,29 +4,41 @@
<div class="col-sm-9">{{ config.APP_VERSION }}</div>
</div>
<div class="row">
- <div class="col-sm-3"><strong>{{ _('Copyright') }}</strong></div>
- <div class="col-sm-9">{{ config.APP_COPYRIGHT }}</div>
+ <div class="col-sm-3"><strong>{{ _('Application Mode') }}</strong></div>
+ <div class="col-sm-9">{{ info.app_mode }}</div>
</div>
<div class="row">
- <div class="col-sm-3"><strong>{{ _('Python Version') }}</strong></div>
- <div class="col-sm-9">{{ info.python_version }}</div>
+ <div class="col-sm-3"><strong>{{ _('Current User') }}</strong></div>
+ <div class="col-sm-9">{{ info.current_user }}</div>
</div>
+ {% if info.nwjs %}
+ <div class="row">
+ <div class="col-sm-3"><strong>{{ _('NW.js Version') }}</strong></div>
+ <div class="col-sm-9">{{ info.nwjs }}</div>
+ </div>
+ {% endif %}
<div class="row">
- <div class="col-sm-3"><strong>{{ _('Flask Version') }}</strong></div>
- <div class="col-sm-9">{{ info.flask_version }}</div>
+ <div class="col-sm-3"><strong>{{ _('Browser Details') }}</strong></div>
+ <div class="col-sm-9">{{ info.browser_details }}</div>
</div>
<div class="row">
- <div class="col-sm-3"><strong>{{ _('Application Mode') }}</strong></div>
- <div class="col-sm-9">{{ info.app_mode }}</div>
+ <div class="col-sm-3"><strong>{{ _('OS') }}</strong></div>
+ <div class="col-sm-9">{{ info.os_details }}</div>
</div>
<div class="row">
- <div class="col-sm-3"><strong>{{ _('Current User') }}</strong></div>
- <div class="col-sm-9">{{ info.current_user }}</div>
+ <div class="col-sm-3"><strong>{{ _('Config DB') }}</strong></div>
+ <div class="col-sm-9">{{ info.config_db }}</div>
+ </div>
+ <div class="row">
+ <div class="col-sm-3"><strong>{{ _('Log file') }}</strong></div>
+ <div class="col-sm-9">{{ info.log_file }}</div>
+ </div>
+ {%if (info.app_mode == 'Desktop') or (info.app_mode == 'Server' and info.admin)%}
+ <div class="row">
+ <div class="col-sm-3"><b>{{ _('Server Configuration') }}</b></div>
</div>
<div class="row">
- <div class="col-12 text-right"><img
- src="{{ url_for('static', filename='img/logo-right-128.png') }}"
- alt="{{ config.APP_NAME }} {{ _('logo') }}"
- ></div>
+ <div class="col-sm-3"><textarea rows="7" cols="85" style="white-space: nowrap;">{{ info.settings|safe }}</textarea></div>
</div>
+ {% endif %}
</div>
view thread (13+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin][RM6231]- Add OS, Browser details in pgAdmin About us pop-up
In-Reply-To: <CAJ9T6Svgp3gKnyRNjS-XkX69e-kNXUDU1BesV1s=ESgNxp2GAA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox