Show all defaults in /admin/config if not set in database, hide configs set by...

Show all defaults in /admin/config if not set in database, hide configs set by config file/CLI/env, add redis config
parent 3af9ce3d
...@@ -276,6 +276,30 @@ ...@@ -276,6 +276,30 @@
</div> </div>
</div> </div>
<div class="config-section">
<h2 class="section-title">Redis Settings</h2>
<div class="form-row">
<div class="form-group">
<label for="redis_host">Redis Host</label>
<input type="text" id="redis_host" name="redis_host" value="{{ current_config.get('redis_host', '') }}">
</div>
<div class="form-group">
<label for="redis_port">Redis Port</label>
<input type="number" id="redis_port" name="redis_port" value="{{ current_config.get('redis_port', '') }}">
</div>
<div class="form-group">
<label for="redis_db">Redis Database</label>
<input type="number" id="redis_db" name="redis_db" value="{{ current_config.get('redis_db', '') }}">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="redis_password">Redis Password</label>
<input type="password" id="redis_password" name="redis_password" value="{{ current_config.get('redis_password', '') }}">
</div>
</div>
</div>
<button type="submit" class="btn-submit">Save Configuration</button> <button type="submit" class="btn-submit">Save Configuration</button>
</form> </form>
</div> </div>
......
...@@ -405,16 +405,36 @@ def config(): ...@@ -405,16 +405,36 @@ def config():
cluster_token = request.form.get('cluster_token', '') cluster_token = request.form.get('cluster_token', '')
set_cluster_token(cluster_token) set_cluster_token(cluster_token)
# Redis Settings
redis_host = request.form.get('redis_host', 'localhost')
set_redis_host(redis_host)
redis_port = int(request.form.get('redis_port', '6379'))
set_redis_port(redis_port)
redis_db = int(request.form.get('redis_db', '0'))
set_redis_db(redis_db)
redis_password = request.form.get('redis_password', '')
set_redis_password(redis_password)
flash('Configuration updated successfully!', 'success') flash('Configuration updated successfully!', 'success')
# Get current database settings (runtime changeable) # Get visible configs: show defaults if not in database, but hide configs set by config file/CLI/env
from .config import get_all_config from .config import get_all_config
current_config = get_all_config() from .config_loader import DEFAULTS, load_initial_config
database_config = get_all_config()
initial_config = load_initial_config()
visible_config = {}
for key in DEFAULTS:
if initial_config.get(key) != DEFAULTS.get(key):
continue # hide if set by config file/CLI/env
visible_config[key] = database_config.get(key, DEFAULTS.get(key))
return render_template('admin/config.html', return render_template('admin/config.html',
user=user, user=user,
current_config=current_config, current_config=visible_config,
active_page='config') active_page='config')
@admin_bp.route('/settings') @admin_bp.route('/settings')
......
...@@ -489,3 +489,44 @@ def get_backend_worker_port() -> int: ...@@ -489,3 +489,44 @@ def get_backend_worker_port() -> int:
def set_backend_worker_port(port: int) -> None: def set_backend_worker_port(port: int) -> None:
"""Set backend worker communication port.""" """Set backend worker communication port."""
set_config('backend_worker_port', str(port)) set_config('backend_worker_port', str(port))
# Redis settings
def get_redis_host() -> str:
"""Get Redis host."""
return get_config('redis_host', 'localhost')
def set_redis_host(host: str) -> None:
"""Set Redis host."""
set_config('redis_host', host)
def get_redis_port() -> int:
"""Get Redis port."""
return int(get_config('redis_port', '6379'))
def set_redis_port(port: int) -> None:
"""Set Redis port."""
set_config('redis_port', str(port))
def get_redis_db() -> int:
"""Get Redis database."""
return int(get_config('redis_db', '0'))
def set_redis_db(db: int) -> None:
"""Set Redis database."""
set_config('redis_db', str(db))
def get_redis_password() -> str:
"""Get Redis password."""
return get_config('redis_password', '')
def set_redis_password(password: str) -> None:
"""Set Redis password."""
set_config('redis_password', password)
\ No newline at end of file
...@@ -86,6 +86,10 @@ DEFAULTS = { ...@@ -86,6 +86,10 @@ DEFAULTS = {
'backend_host': 'localhost', 'backend_host': 'localhost',
'backend_web_port': '5001', 'backend_web_port': '5001',
'backend_worker_port': '5002', 'backend_worker_port': '5002',
'redis_host': 'localhost',
'redis_port': '6379',
'redis_db': '0',
'redis_password': '',
'jwt_secret_key': 'vidai-jwt-secret-key-change-in-production' 'jwt_secret_key': 'vidai-jwt-secret-key-change-in-production'
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment