public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pradip Parkale <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin][RM6231]- Add OS, Browser details in pgAdmin About us pop-up
Date: Tue, 1 Jun 2021 14:02:48 +0530
Message-ID: <CAJ9T6Sv57RtY29R6ybac947O5N50UtK1ezXCk8Pa53O0SZVi=g@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDdvJewB488GhL-ByzGuVERto=3Bw=w9ObyR8meK3qDQYA@mail.gmail.com>
References: <CAJ9T6Svgp3gKnyRNjS-XkX69e-kNXUDU1BesV1s=ESgNxp2GAA@mail.gmail.com>
	<CANxoLDdvJewB488GhL-ByzGuVERto=3Bw=w9ObyR8meK3qDQYA@mail.gmail.com>

Hi Akshay,

Please find an updated patch.


On Mon, May 24, 2021 at 4:45 PM Akshay Joshi <[email protected]>
wrote:

> Hi Pradip
>
> Following are the review comments:
>
>    - Following labels should be changed
>       - Browser Details -> Browser
>       - OS -> Operating System
>       - Config DB -> pgAdmin Database File
>
> Done.

>
>    - Server Configuration Text Area should be *readonly* and it should
>    have a "col-sm-9" class instead of "col-sm-3".
>
> Done.

>
>    - If the user resizes the About dialog then instead of showing blank
>    space can we automatically resize the Server configuration text area?
>
> Done.

>
>    - The height of the About dialog in the Server mode should be less as
>    we are not showing "Server Configuration".
>
> Done.

>
>    - In Runtime, we should merge the 'Browser details' in 'NW.js version'
>    like *0.51.2 (Chromium 89.0.4389.114)* OR at least prefix 'Chromium'
>    before the version in the 'Browser details'.
>
> Done.

>
>    - Found string difference in OS details for Runtime and Desktop mode.
>       - OSX: "Intel Mac OS X 10_15_7" in Runtime, while "Mac OS X
>       10.15.7" in Dekstop mode.
>       - Windows: "Win64" in Runtime, while "Windows 10" in Desktop which
>       also not correct, I am using "Windows Server 2016".
>    - Following issue found on Firefox (First Image) configuration in a
>    single line, Safari (Second image) too many scroll bars.
>
> Done.

>                   [image: Firefox.png].      [image: Safari.png]
>
> On Fri, May 21, 2021 at 2:23 PM Pradip Parkale <
> [email protected]> wrote:
>
>> 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
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [image/png] Firefox.png (122.7K, 3-Firefox.png)
  download | view image

  [image/png] Safari.png (154.4K, 4-Safari.png)
  download | view image

  [application/octet-stream] RM6231_v2.patch (8.2K, 5-RM6231_v2.patch)
  download | inline diff:
diff --git a/requirements.txt b/requirements.txt
index a14774736..e3133e368 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -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.*
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..a27248559 100644
--- a/web/pgadmin/about/__init__.py
+++ b/web/pgadmin/about/__init__.py
@@ -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():
diff --git a/web/pgadmin/about/static/js/about.js b/web/pgadmin/about/static/js/about.js
index c6c73e6c2..4dfa6b149 100644
--- a/web/pgadmin/about/static/js/about.js
+++ b/web/pgadmin/about/static/js/about.js
@@ -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);
+            }
           });
       },
     };
diff --git a/web/pgadmin/about/templates/about/index.html b/web/pgadmin/about/templates/about/index.html
index 607e6c298..e1c94f0bf 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') }}</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>{{ _('Operating System') }}</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>{{ _('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-12 text-right"><img
-            src="{{ url_for('static', filename='img/logo-right-128.png') }}"
-            alt="{{ config.APP_NAME }} {{ _('logo') }}"
-        ></div>
+        <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>


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], [email protected]
  Subject: Re: [pgAdmin][RM6231]- Add OS, Browser details in pgAdmin About us pop-up
  In-Reply-To: <CAJ9T6Sv57RtY29R6ybac947O5N50UtK1ezXCk8Pa53O0SZVi=g@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