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 *\
RWNoX3I5d^;Hg=#hACu=B=HrR#7i($?^kujKn2ND*@5ZTnvUhFzoynF9*&TI#Bb z*ff %OS{}ztNIG2{u#uH!Goz6R6Ir;dSE)J&2-8b 1dt|wT;c5 z#J|$RG}%L?K(AlUZ(FM(_hNwT$T3=Oy`M55Gp=8`u%(M7Jg^vhOsU*grTp!Gu~t9Z z4P&&4YvJ%mh;T2VUy7pZVP&Q}@1t~MWp3bbHW~mkdveX*&56}^4Z&6l%Ha4F Ya zyy+u+L@c`+j?LNZFOL2Jgi}ZP1xOksrG#buhPCRnSZOxt8sM3t(b6UzM*IffpO}Za z>}>}SfZ>>_*vLcS0?usO!!rp^uu${HU(+w{Lg=d_xuLlCIzCSU?6>7Rqo*&leihXE zviCxzggj+5XM$AKytCW+WE8LIG1^PdU$qwe)s(h%lSV_}o+8NY0M@*bJ<=Hh0zS4a za?BG*BO}ln>^^}YXV7!u|Kp;Pka?Lz(TQ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