mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-25 10:10:19 -06:00
Added OS, Browser, Configuration details in the About dialog. Fixes #6231
This commit is contained in:
parent
e0eac875b6
commit
2c51925638
@ -11,6 +11,7 @@ New features
|
||||
|
||||
| `Issue #2341 <https://redmine.postgresql.org/issues/2341>`_ - Added support to launch PSQL for the connected database server.
|
||||
| `Issue #4064 <https://redmine.postgresql.org/issues/4064>`_ - Added window maximize/restore functionality for properties dialog.
|
||||
| `Issue #6231 <https://redmine.postgresql.org/issues/6231>`_ - Added OS, Browser, Configuration details in the About dialog.
|
||||
| `Issue #6395 <https://redmine.postgresql.org/issues/6395>`_ - Added support to rotate the pgadmin log file on the basis of Size and Age.
|
||||
|
||||
Housekeeping
|
||||
|
@ -38,3 +38,5 @@ Flask-BabelEx==0.*
|
||||
gssapi==1.6.*
|
||||
flask-socketio>=5.0.1
|
||||
eventlet==0.30.2
|
||||
httpagentparser==1.9.*
|
||||
user_agents==2.2.*
|
||||
|
@ -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,
|
||||
|
@ -10,13 +10,16 @@
|
||||
"""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
|
||||
from user_agents import parse
|
||||
|
||||
MODULE_NAME = 'about'
|
||||
|
||||
@ -59,23 +62,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')
|
||||
user_agent = parse(agent)
|
||||
|
||||
if 'Nwjs' in agent:
|
||||
agent = agent.split('-')
|
||||
nwjs_version = agent[0].split(':')[1]
|
||||
browser = 'Chromium' + ' ' + agent[2]
|
||||
os_details = user_agent.os.family + ' ' + user_agent.os.version_string
|
||||
|
||||
else:
|
||||
browser = httpagentparser.detect(agent)
|
||||
os_details = user_agent.os.family + ' ' + user_agent.os.version_string
|
||||
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():
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
define(
|
||||
['jquery', 'alertify', 'sources/pgadmin', 'sources/gettext',
|
||||
'sources/url_for','sources/utils',
|
||||
'sources/url_for','sources/utils','pgadmin.user_management.current_user',
|
||||
],
|
||||
function($, alertify, pgAdmin, gettext, url_for, commonUtils) {
|
||||
function($, alertify, pgAdmin, gettext, url_for, commonUtils, current_user) {
|
||||
pgAdmin = pgAdmin || window.pgAdmin || {};
|
||||
|
||||
/* Return back, this has been called more than once */
|
||||
@ -52,7 +52,6 @@ define(
|
||||
|
||||
prepare:function() {
|
||||
this.setContent(this.message);
|
||||
|
||||
},
|
||||
};
|
||||
});
|
||||
@ -60,9 +59,15 @@ define(
|
||||
|
||||
$.get(url_for('about.index'),
|
||||
function(data) {
|
||||
alertify.aboutDialog(
|
||||
gettext('About %s', pgAdmin.Browser.utils.app_name), data
|
||||
).resizeTo(pgAdmin.Browser.stdW.md, pgAdmin.Browser.stdH.md);
|
||||
if(!current_user.is_admin && pgAdmin.server_mode){
|
||||
alertify.aboutDialog(
|
||||
gettext('About %s', pgAdmin.Browser.utils.app_name), data
|
||||
).resizeTo(pgAdmin.Browser.stdW.md, 300);
|
||||
}else{
|
||||
alertify.aboutDialog(
|
||||
gettext('About %s', pgAdmin.Browser.utils.app_name), data
|
||||
).resizeTo(750, 470);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@ -3,18 +3,6 @@
|
||||
<div class="col-sm-3"><strong>{{ _('Version') }}</strong></div>
|
||||
<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>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><strong>{{ _('Python Version') }}</strong></div>
|
||||
<div class="col-sm-9">{{ info.python_version }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><strong>{{ _('Flask Version') }}</strong></div>
|
||||
<div class="col-sm-9">{{ info.flask_version }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><strong>{{ _('Application Mode') }}</strong></div>
|
||||
<div class="col-sm-9">{{ info.app_mode }}</div>
|
||||
@ -23,10 +11,34 @@
|
||||
<div class="col-sm-3"><strong>{{ _('Current User') }}</strong></div>
|
||||
<div class="col-sm-9">{{ info.current_user }}</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>
|
||||
{% 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>{{ _('Browser') }}</strong></div>
|
||||
<div class="col-sm-9">{{ info.browser_details }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><strong>{{ _('Operating System') }}</strong></div>
|
||||
<div class="col-sm-9">{{ info.os_details }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3"><strong>{{ _('pgAdmin Database File') }}</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-sm-9"><textarea rows="7" cols="85" style="width:120%; height: 120%; white-space: pre-wrap;" readonly>{{ info.settings|safe }}</textarea></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user