From fd70164f82e6683b66ef6ec1e30c14443cfb682f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Wed, 2 Aug 2023 16:59:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20PGAdmin4=20(#246)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 添加 PGAdmin4 --- apps/pgadmin4/7.4/data.yml | 24 +++ apps/pgadmin4/7.4/docker-compose.yml | 21 ++ apps/pgadmin4/README.md | 286 +++++++++++++++++++++++++++ apps/pgadmin4/data.yml | 19 ++ apps/pgadmin4/logo.png | Bin 0 -> 6001 bytes 5 files changed, 350 insertions(+) create mode 100644 apps/pgadmin4/7.4/data.yml create mode 100644 apps/pgadmin4/7.4/docker-compose.yml create mode 100644 apps/pgadmin4/README.md create mode 100644 apps/pgadmin4/data.yml create mode 100644 apps/pgadmin4/logo.png diff --git a/apps/pgadmin4/7.4/data.yml b/apps/pgadmin4/7.4/data.yml new file mode 100644 index 000000000..ba210e773 --- /dev/null +++ b/apps/pgadmin4/7.4/data.yml @@ -0,0 +1,24 @@ +additionalProperties: + formFields: + - default: 80 + edit: true + envKey: PANEL_APP_PORT_HTTP + labelEn: Web Port + labelZh: Web 端口 + required: true + rule: paramPort + type: number + - default: admin@1panel.cn + edit: true + envKey: PGADMIN_DEFAULT_EMAIL + labelEn: Admin Email + labelZh: 管理员邮箱 + required: true + type: text + - default: hgraZPD3v00I5AwuzSpL + edit: true + envKey: PGADMIN_DEFAULT_PASSWORD + labelEn: Admin Password + labelZh: 管理员密码 + required: true + type: password diff --git a/apps/pgadmin4/7.4/docker-compose.yml b/apps/pgadmin4/7.4/docker-compose.yml new file mode 100644 index 000000000..d06e34591 --- /dev/null +++ b/apps/pgadmin4/7.4/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3.8' +services: + pgadmin4: + image: dpage/pgadmin4:7.4 + container_name: ${CONTAINER_NAME} + restart: always + labels: + createdBy: "Apps" + environment: + PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL} + PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD} + ports: + - ${PANEL_APP_PORT_HTTP}:80 + volumes: + - ./data:/var/lib/pgadmin + networks: + - 1panel-network + +networks: + 1panel-network: + external: true \ No newline at end of file diff --git a/apps/pgadmin4/README.md b/apps/pgadmin4/README.md new file mode 100644 index 000000000..6f751675b --- /dev/null +++ b/apps/pgadmin4/README.md @@ -0,0 +1,286 @@ +# pgAdmin 4 + +pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the +PostgreSQL (http://www.postgresql.org) database. + +In the following documentation and examples, *$PGADMIN4_SRC/* is used to denote +the top-level directory of a copy of the pgAdmin source tree, either from a +tarball or a git checkout. + +## Architecture + +pgAdmin 4 is written as a web application in Python, using jQuery and Bootstrap +for the client side processing and UI. On the server side, Flask is being +utilised. + +Although developed using web technologies, pgAdmin 4 can be deployed either on +a web server using a browser, or standalone on a workstation. The runtime/ +subdirectory contains an NWjs based runtime application intended to allow this, +which will execute the Python server and display the UI. + +## Building the Runtime + +To build the runtime, the following packages must be installed: + +* NodeJS 12+ +* Yarn + +Change into the runtime directory, and run *yarn install*. This will install the +dependencies required. + +In order to use the runtime in a development environment, you'll need to copy +*dev_config.json.in* file to *dev_config.json*, and edit the paths to the Python +executable and *pgAdmin.py* file, otherwise the runtime will use the default +paths it would expect to find in the standard package for your platform. + +You can then execute the runtime by running something like: + +```bash +node_modules/nw/nwjs/nw . +``` + +or on macOS: + +```bash +node_modules/nw/nwjs/nwjs.app/Contents/MacOS/nwjs . +``` + +# Configuring the Python Environment + +In order to run the Python code, a suitable runtime environment is required. +Python version 3.7 and later are currently supported. It is recommended that a +Python Virtual Environment is setup for this purpose, rather than using the +system Python environment. On Linux and Mac systems, the process is fairly +simple - adapt as required for your distribution: + +1. Create a virtual environment in an appropriate directory. The last argument is + the name of the environment; that can be changed as desired: + + ```bash + $ python3 -m venv venv + ``` + +2. Now activate the virtual environment: + + ```bash + $ source venv/bin/activate + ``` + +3. Some of the components used by pgAdmin require a very recent version of *pip*, + so update that to the latest: + + ```bash + $ pip install --upgrade pip + ``` + +4. Ensure that a PostgreSQL installation's bin/ directory is in the path (so + pg_config can be found for building psycopg3), and install the required + packages: + + ```bash + (venv) $ PATH=$PATH:/usr/local/pgsql/bin pip install -r $PGADMIN4_SRC/requirements.txt + ``` + + If you are planning to run the regression tests, you also need to install + additional requirements from web/regression/requirements.txt: + + ```bash + (venv) $ pip install -r $PGADMIN4_SRC/web/regression/requirements.txt + ``` + +5. Create a local configuration file for pgAdmin. Edit + $PGADMIN4_SRC/web/config_local.py and add any desired configuration options + (use the config.py file as a reference - any settings duplicated in + config_local.py will override those in config.py). A typical development + configuration may look like: + + ```python + from config import * + + # Debug mode + DEBUG = True + + # App mode + SERVER_MODE = True + + # Enable the test module + MODULE_BLACKLIST.remove('test') + + # Log + CONSOLE_LOG_LEVEL = DEBUG + FILE_LOG_LEVEL = DEBUG + + DEFAULT_SERVER = '127.0.0.1' + + UPGRADE_CHECK_ENABLED = True + + # Use a different config DB for each server mode. + if SERVER_MODE == False: + SQLITE_PATH = os.path.join( + DATA_DIR, + 'pgadmin4-desktop.db' + ) + else: + SQLITE_PATH = os.path.join( + DATA_DIR, + 'pgadmin4-server.db' + ) + ``` + + This configuration allows easy switching between server and desktop modes + for testing. + +6. The initial setup of the configuration database is interactive in server + mode, and non-interactive in desktop mode. You can run it either by + running: + + ```bash + (venv) $ python3 $PGADMIN4_SRC/web/setup.py + ``` + + or by starting pgAdmin 4: + + ```bash + (venv) $ python3 $PGADMIN4_SRC/web/pgAdmin4.py + ``` + + Whilst it is possible to automatically run setup in desktop mode by running + the runtime, that will not work in server mode as the runtime doesn't allow + command line interaction with the setup program. + +At this point you will be able to run pgAdmin 4 from the command line in either +server or desktop mode, and access it from a web browser using the URL shown in +the terminal once pgAdmin has started up. + +Setup of an environment on Windows is somewhat more complicated unfortunately, +please see *pkg/win32/README.txt* for complete details. + +# Building the Web Assets + +pgAdmin is dependent on a number of third party Javascript libraries. These, +along with it's own Javascript code, SCSS/CSS code and images must be +compiled into a "bundle" which is transferred to the browser for execution +and rendering. This is far more efficient than simply requesting each +asset as it's needed by the client. + +To create the bundle, you will need the 'yarn' package management tool to be +installed. Then, you can run the following commands on a *nix system to +download the required packages and build the bundle: + +```bash +(venv) $ cd $PGADMIN4_SRC +(venv) $ make install-node +(venv) $ make bundle +``` + +On Windows systems (where "make" is not available), the following commands +can be used: + +``` +C:\> cd $PGADMIN4_SRC\web +C:\$PGADMIN4_SRC\web> yarn install +C:\$PGADMIN4_SRC\web> yarn run bundle +``` + +# Creating pgAdmin themes + +To create a pgAdmin theme, you need to create a directory under +*web/pgadmin/static/scss/resources*. +Copy the sample file *_theme.variables.scss.sample* to the new directory and +rename it to *_theme.variables.scss*. Change the desired hexadecimal values of +the colors and bundle pgAdmin. You can also add a preview image in the theme +directory with the name as *\_preview.png*. It is recommended that the +preview image should not be larger in size as it may take time to load on slow +networks. Run the *yarn run bundle* and you're good to go. No other changes are +required, pgAdmin bundle will read the directory and create other required +entries to make them available in preferences. + +The name of the theme is derived from the directory name. Underscores (_) and +hyphens (-) will be replaced with spaces and the result will be camel cased. + +# Building the documentation + +In order to build the docs, an additional Python package is required in the +virtual environment. This can be installed with the pip package manager: + +```bash +$ source venv/bin/activate +(venv) $ pip install Sphinx +(venv) $ pip install sphinxcontrib-youtube +``` + +The docs can then be built using the Makefile in *$PGADMIN4_SRC*, e.g. + +```bash +(venv) $ make docs +``` + +The output can be found in *$PGADMIN4_SRC/docs/en_US/_build/html/index.html* + +# Building packages + +Most packages can be built using the Makefile in $PGADMIN4_SRC, provided all +the setup and configuration above has been completed. + +To build a source tarball: + +```bash +(venv) $ make src +``` + +To build a PIP Wheel, activate either a Python 3 virtual environment, configured +with all the required packages, and then run: + +```bash +(venv) $ make pip +``` + +To build the macOS AppBundle, please see *pkg/mac/README*. + +To build the Windows installer, please see *pkg/win32/README.txt*. +# Create Database Migrations + +In order to make changes to the SQLite DB, navigate to the 'web' directory: + +```bash +(venv) $ cd $PGADMIN4_SRC/web +``` + +Create a migration file with the following command: + +```bash +(venv) $ FLASK_APP=pgAdmin4.py flask db revision +``` + +This will create a file in: $PGADMIN4_SRC/web/migrations/versions/ . +Add any changes to the 'upgrade' function. +Increment the SCHEMA_VERSION in $PGADMIN4_SRC/web/pgadmin/model/__init__.py file. + +There is no need to increment the SETTINGS_SCHEMA_VERSION. + +# Support + +See https://www.pgadmin.org/support/ for support options. + +# Security Issues + +If you would like to report a security issue with pgAdmin, please email +**security (at) pgadmin (dot) org**. + +Note that this address should only be used for reporting security issues +that you believe you've found in the design or code of pgAdmin, pgAgent, +and the pgAdmin website. It should not be used to ask security questions. + +# Project info + +A GitHub project for pgAdmin 4 can be found at the address below: + +https://github.com/pgadmin-org/pgadmin4 + +Please submit any changes as Pull Requests against the *master* branch of the +*pgadmin-org/pgadmin4* repository. + +If you wish to discuss pgAdmin 4, or contribute to the project, please use the +pgAdmin Hackers mailing list: + +pgadmin-hackers@postgresql.org \ No newline at end of file diff --git a/apps/pgadmin4/data.yml b/apps/pgadmin4/data.yml new file mode 100644 index 000000000..22fb4cbab --- /dev/null +++ b/apps/pgadmin4/data.yml @@ -0,0 +1,19 @@ +name: PGAdmin4 +tags: + - 工具 +title: PostgreSQL 开源管理工具 +type: 工具 +description: PostgreSQL 开源管理工具 +additionalProperties: + key: pgadmin4 + name: PGAdmin4 + tags: + - Tool + shortDescZh: PGAdmin4 是 Postgres 的开源管理工具。 + shortDescEn: PGAdmin4 is an open source management tool for Postgres. + type: tool + crossVersionUpdate: true + limit: 1 + website: https://www.pgadmin.org + github: https://github.com/pgadmin-org/pgadmin4 + document: https://www.pgadmin.org/docs \ No newline at end of file diff --git a/apps/pgadmin4/logo.png b/apps/pgadmin4/logo.png new file mode 100644 index 0000000000000000000000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