Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@ PGWEB_DATABASE_URL=postgres://pgweb_dev:pgweb_dev_password@postgres:5432/pgweb_t
PGWEB_CUSTOM_PARAMS="Client,Instance,ClientName,InstanceName,AccountId,AccountPerspective,AccountDbUser,AccountName,AccountEmail,FolderName"

# Test role for RLS (Issue #15) - used for testing multi-tenancy
PGWEB_TEST_ROLE=test_tenant_role
PGWEB_TEST_ROLE=test_tenant_role

# Font Configuration for Testing
PGWEB_FONT_FAMILY=Space Grotesk, sans-serif
PGWEB_FONT_SIZE=15px
PGWEB_GOOGLE_FONTS=Space Grotesk:300,400,500,600,700

# Query and Metadata Caching Configuration
PGWEB_DISABLE_QUERY_CACHE=false # Disable query result caching
PGWEB_DISABLE_METADATA_CACHE=false # Disable metadata caching for schemas, tables, etc.
PGWEB_QUERY_CACHE_TTL=300 # Query cache TTL in seconds - how long SELECT query results are cached
PGWEB_METADATA_CACHE_TTL=600 # Metadata cache TTL in seconds - how long schema/table info is cached
54 changes: 53 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
## Changelog

Current [release](https://github.com/flowbi/pgweb/releases) is `0.16.5`.
Current [release](https://github.com/flowbi/pgweb/releases) is `0.16.14`.

## 0.16.14 - 2025-09-01

- `NEW` Enable font customization
- `NEW` Implement in-memory query caching to improve performance

## 0.16.13 - 2025-08-31

- `NEW` Introduce configuration of custom parameter during server configuration
- `NEW` Optimized local dev setup for testing through docker-compose.dev
- `NEW` Implement Runtime Query File Replacement for custom constraints
- `NEW` Implement Flow.bi custom constraints query with safe fallback to standard PostgreSQL constraints
- `FIX` Update ace-pgsql.js SQL keyword highlighting

## 0.16.12 - 2025-08-30

- `FIX` Update Font Awesome link to use CDN for resolving font issue

## 0.16.11 - 2025-08-29

- `FIX` Update Font Awesome font relative paths in CSS to absolute
- `FIX` Enhance parameter overlay management
- `FIX` 'hideParamIndicator' in URL and hide overlay in tabs other than Query

## 0.16.10 - 2025-08-28

- `NEW` Support @parameters in queries
- `NEW` Streamline development setup with Docker, helper script and .env\* file
- `FIX` Update CI workflow and remove obsolete test file

## 0.16.9 - 2025-08-27

- `NEW` Add an option to hide active parameter overlay

## 0.16.8 - 2025-08-26

- `NEW` Implement URL parameter substitution SQL queries for iframe embedding
- `FIX` Fix formatting issues

## 0.16.7 - 2025-08-25

- `NEW` Add schema and object filtering options
- `NEW` Add hyper link support
- `FIX` Time out 504 error in /rows when selecting foreign table and hide table information from UI
- `FIX` Update PostgreSQL version matrix in GitHub workflow
- `FIX` Formatting issues

## 0.16.6 - 2025-08-24

- `FIX` Set CGO_ENABLED only for docker-build jobs and remove globally
- `FIX` Update project references to flowbi
- `FIX` Optimize GitHub Actions workflows to save on CI/CD time

## 0.16.5 - 2025-08-22

Expand Down
4 changes: 2 additions & 2 deletions dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ case "$ACTION" in

# Test parameter substitution
echo_info "Test URL with parameters:"
echo_info "http://localhost:8081/?Client=client&Instance=instance&ClientName=clientname&InstanceName=instance-name&AccountId=account-id&AccountPerspective=account-perspective&AccountDbUser=account-db-user&AccountName=account-name&AccountEmail=account-email&FolderName=folder-name&InvalidParameter=shouldnotshow"
echo_info "http://localhost:8081/?Client=client&Instance=instance&ClientName=client-name&InstanceName=instance-name&AccountId=account-id&AccountPerspective=account-perspective&AccountDbUser=account-db-user&AccountName=account-name&AccountEmail=account-email&FolderName=folder-name&InvalidParameter=shouldnotshow"
;;

"stop"|"down")
Expand Down Expand Up @@ -131,7 +131,7 @@ case "$ACTION" in
echo_info "Testing parameter substitution..."
sleep 2
echo_info "Opening pgweb with test parameters..."
open "http://localhost:8081/?Client=client&Instance=instance&ClientName=clientname&InstanceName=instance-name&AccountId=account-id&AccountPerspective=account-perspective&AccountDbUser=account-db-user&AccountName=account-name&AccountEmail=account-email&FolderName=folder-name&InvalidParameter=shouldnotshow" 2>/dev/null || echo_warning "Could not open browser automatically"
open "http://localhost:8081/?Client=client&Instance=instance&ClientName=client-name&InstanceName=instance-name&AccountId=account-id&AccountPerspective=account-perspective&AccountDbUser=account-db-user&AccountName=account-name&AccountEmail=account-email&FolderName=folder-name&InvalidParameter=shouldnotshow" 2>/dev/null || echo_warning "Could not open browser automatically"
;;

"help"|*)
Expand Down
10 changes: 9 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ services:
postgres:
condition: service_healthy
environment:
# Default to local postgres for development
# Override PGWEB_DATABASE_URL for production with URL-encoded password
PGWEB_DATABASE_URL: ${PGWEB_DATABASE_URL:-postgres://pgweb_dev:pgweb_dev_password@postgres:5432/pgweb_test?sslmode=disable}
PGWEB_TEST_ROLE: ${PGWEB_TEST_ROLE}
PGWEB_CUSTOM_PARAMS: ${PGWEB_CUSTOM_PARAMS}
# Font configuration
PGWEB_FONT_FAMILY: ${PGWEB_FONT_FAMILY}
PGWEB_FONT_SIZE: ${PGWEB_FONT_SIZE}
PGWEB_GOOGLE_FONTS: ${PGWEB_GOOGLE_FONTS}
# Query and metadata caching configuration
PGWEB_DISABLE_QUERY_CACHE: ${PGWEB_DISABLE_QUERY_CACHE}
PGWEB_DISABLE_METADATA_CACHE: ${PGWEB_DISABLE_METADATA_CACHE}
PGWEB_QUERY_CACHE_TTL: ${PGWEB_QUERY_CACHE_TTL}
PGWEB_METADATA_CACHE_TTL: ${PGWEB_METADATA_CACHE_TTL}
command:
[
"./pgweb",
Expand Down
86 changes: 86 additions & 0 deletions docs/development-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# pgweb Development Setup

Simple one-command development environment for pgweb with PostgreSQL and parameter substitution.

## Quick Start

```bash
# Start development environment (builds automatically)
./dev.sh start

# Access pgweb: http://localhost:8081
# Access postgres: localhost:5433
```

## Commands

```bash
./dev.sh start # Start development environment
./dev.sh stop # Stop development environment
./dev.sh restart # Restart and rebuild
./dev.sh logs # Show logs (add service name: logs pgweb)
./dev.sh clean # Clean up containers and volumes
./dev.sh test # Test parameter substitution
./dev.sh help # Show help
```

## Parameter Substitution

The system automatically replaces `@parameter` placeholders in SQL queries with URL parameters.

**Example:**

- URL: `http://localhost:8081/?Client=client&Instance=instance&ClientName=client-name&InstanceName=instance-name&AccountId=account-id&AccountPerspective=account-perspective&AccountDbUser=account-db-user&AccountName=account-name&AccountEmail=account-email&FolderName=folder-name&InvalidParameter=shouldnotshow`
- Query: `SELECT * FROM table WHERE client = @Client AND instance = @Instance`
- Executed: `SELECT * FROM table WHERE client = 'test-client' AND instance = 'test-instance'`

**Custom Parameters:**

Parameters are configurable via the `PGWEB_CUSTOM_PARAMS` environment variable. Default parameters include:

- `Client`, `Instance`, `ClientName`, `InstanceName`
- `AccountId`, `AccountPerspective`, `AccountDbUser`
- `AccountName`, `AccountEmail`, `FolderName`

You can customize these by setting `PGWEB_CUSTOM_PARAMS` in your `.env` file with a comma-separated list of parameter names.

## Production Database

For production database with special characters in password:

```bash
# Set environment variables
export DB_USER="your_username"
export SQL_API_PASSWORD="your*pa$$@word" # Special chars auto-encoded
export SQL_API_HOST="your.database.host"
export DB_NAME="your_database"

# Start with production database
./dev.sh start
```

## Docker Compose Only

If you prefer direct docker-compose:

```bash
# Local development
docker-compose up -d

# Production database
DATABASE_URL="postgres://user:encoded_password@host:5432/db" docker-compose up -d
```

## How It Works

1. **No Separate Build Step**: Docker builds the binary automatically during `docker-compose up`
2. **Automatic Password Encoding**: Special characters in passwords are URL-encoded automatically
3. **Frontend Parameter Substitution**: JavaScript replaces `@parameters` before sending queries to backend
4. **One File**: Everything configured in single `docker-compose.yml`

## Files

- `docker-compose.yml` - Main configuration (safe to commit)
- `dev.sh` - Helper script with password encoding
- `.env` - Secrets (never committed)
- `.env.example` - Template for environment variables
Loading
Loading