Implemented runtime using NWjs to open pgAdmin4 in a standalone window

instead of the system tray and web browser. Used NWjs to get rid of QT
and C++. Fixes #5967

Use cheroot as the default production server for pgAdmin4. Fixes #5017
This commit is contained in:
Akshay Joshi
2021-01-29 13:38:27 +05:30
parent a0271c7656
commit 102ffd141c
392 changed files with 3388 additions and 7599 deletions

View File

@@ -7,14 +7,14 @@
The bulk of pgAdmin is a Python web application written using the Flask framework
on the backend, and HTML5 with CSS3, Bootstrap and jQuery on the front end. A
desktop runtime is also included for users that prefer a desktop application to
a web application, which is written in C++ using the QT framework.
a web application, which is written using NWjs (Node Webkit).
Runtime
*******
The runtime is essentially a Python webserver and browser in a box. Found in the
**/runtime** directory in the source tree, it is a relatively simple QT
application that is most easily modified using the **QT Creator** application.
The runtime is based on NWjs which integrates a browser and the Python server
creating a standalone application. The source code can be found in the
**/runtime** directory in the source tree.
Web Application
***************
@@ -213,4 +213,4 @@ divided each module in small chunks as much as possible. Not all javascript
modules are required to be loaded (i.e. loading a javascript module for
database will make sense only when a server node is loaded completely.) Please
look at the the javascript files node.js, browser.js, menu.js, panel.js, etc for
better understanding of the code.
better understanding of the code.

View File

@@ -109,54 +109,6 @@ names.
.. note:: From version 3.0 onwards, new or refactored code should be written using
ES6 features and conventions.
C++
***
C++ code is used in the desktop runtime for the application, primarily with the
QT framework and an embedded Python interpreter. Note the use of hanging braces,
which may be omitted if on a single statement is present:
.. code-block:: c++
// Ping the application server to see if it's alive
bool PingServer(QUrl url)
{
QNetworkAccessManager manager;
QEventLoop loop;
QNetworkReply *reply;
QVariant redirectUrl;
url.setPath("/utils/ping");
do
{
reply = manager.get(QNetworkRequest(url));
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
url = redirectUrl.toUrl();
if (!redirectUrl.isNull())
delete reply;
} while (!redirectUrl.isNull());
if (reply->error() != QNetworkReply::NoError)
return false;
QString response = reply->readAll();
if (response != "PING")
{
qDebug() << "Failed to connect, server response: " << response;
return false;
}
return true;
}
Python
******

View File

@@ -8,13 +8,8 @@ pgAdmin may be deployed as a desktop application by configuring the application
to run in desktop mode and then utilising the desktop runtime to host the
program on a supported Windows, Mac OS X or Linux installation.
The desktop runtime is a system-tray application that when launched, runs the
pgAdmin server and launches a web browser to render the user interface. If
additional instances of pgAdmin are launched, a new browser tab will be opened
and be served by the existing instance of the server in order to minimise system
resource utilisation. Clicking the icon in the system tray will present a menu
offering options to open a new pgAdmin window, configure the runtime, view the
server log and shut down the server.
The desktop runtime is a standalone application that when launched, runs the
pgAdmin server and opens a window to render the user interface.
.. note:: Pre-compiled and configured installation packages are available for
a number of platforms. These packages should be used by end-users whereever
@@ -42,19 +37,26 @@ Runtime
*******
When executed, the runtime will automatically try to execute the pgAdmin Python
application. If execution fails, it will prompt you to adjust the Python Path
to include the directories containing the pgAdmin code as well as any additional
Python dependencies. You can enter a list of paths by separating them with a
semi-colon character, for example:
application. If execution fails, it will prompt you with error message
displaying a *Configure* button at the bottom. You can configure a fixed port
number to avoid clashes of the default random port number with other
applications and a connection timeout if desired.
.. code-block:: bash
If the error is related to Python Path or pgAdmin Python file then you need to
create a file named 'dev_config.json' and specify the following entries:
/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/;/Users/dpage/python-libs/
{
"pythonPath": <PATH OF THE PYTHON BINARY> For Example: "../../venv/bin/python3",
"pgadminFile": <PATH OF THE pgAdmin4.py> For Example: "../web/pgAdmin4.py"
}
The configuration settings are stored using the QSettings class in Qt, which
will use an INI file on Unix systems (~/.config/pgadmin/pgadmin4.conf),
a plist file on Mac OS X (~/Library/Preferences/org.pgadmin.pgadmin4.plist),
and the registry on Windows (HKEY_CURRENT_USER\\Software\\pgadmin\\pgadmin4).
Note that the dev_config.py file should only be required by developers who are
working outside of a standard installation.
The configuration settings are stored in *runtime_config.json* file, which
will be available on Unix systems (~/.local/share/pgadmin/),
on Mac OS X (~/Library/Preferences/pgadmin),
and on Windows (%APPDATA%/pgadmin).
The configuration settings:
@@ -65,18 +67,10 @@ The configuration settings:
+--------------------------+--------------------+---------------------------------------------------------------+
| Key | Type | Purpose |
+==========================+====================+===============================================================+
| ApplicationPath | String | The directory containing pgAdmin4.py |
+--------------------------+--------------------+---------------------------------------------------------------+
| BrowserCommand | String | An alternate command to run instead of the default browser. |
+--------------------------+--------------------+---------------------------------------------------------------+
| ConnectionTimeout | Integer | The number of seconds to wait for application server startup. |
+--------------------------+--------------------+---------------------------------------------------------------+
| FixedPort | Boolean | Use a fixed network port number rather than a random one. |
+--------------------------+--------------------+---------------------------------------------------------------+
| OpenTabAtStartup | Boolean | Open a browser tab at startup. |
+--------------------------+--------------------+---------------------------------------------------------------+
| PortNumber | Integer | The port number to use, if using a fixed port. |
+--------------------------+--------------------+---------------------------------------------------------------+
| PythonPath | String | The Python module search path |
| ConnectionTimeout | Integer | The number of seconds to wait for application server startup. |
+--------------------------+--------------------+---------------------------------------------------------------+

View File

@@ -9,10 +9,12 @@ This release contains a number of bug fixes and new features since the release o
New features
************
| `Issue #5967 <https://redmine.postgresql.org/issues/5967>`_ - Implemented runtime using NWjs to open pgAdmin4 in a standalone window instead of the system tray and web browser.
Housekeeping
************
| `Issue #5017 <https://redmine.postgresql.org/issues/5017>`_ - Use cheroot as the default production server for pgAdmin4.
Bug fixes
*********
@@ -25,8 +27,3 @@ Bug fixes
| `Issue #6177 <https://redmine.postgresql.org/issues/6177>`_ - Fixed an issue while downloading ERD images in Safari and Firefox.
| `Issue #6179 <https://redmine.postgresql.org/issues/6179>`_ - Fixed an issue where Generate SQL displayed twice in the ERD tool.
| `Issue #6180 <https://redmine.postgresql.org/issues/6180>`_ - Updated missing documentation for the 'Download Image' option in ERD.
. Documentation missing for 'Download Image' option in ERD. Fixes #6180.
2. Generate SQL displayed twice in ERD tool. Fixes #6179.
3. Zooming out too far makes the diagram vanish entirely. Fixes #6164.
4. Zoom to fit button only works if the diagram is larger than the canvas. Fixes #6163.