Modify /admin/config to show only database-set configurations, excluding...

Modify /admin/config to show only database-set configurations, excluding database and network configs
parent bc318365
......@@ -125,81 +125,6 @@
</div>
</div>
<div class="config-section">
<h2 class="section-title">Database Settings</h2>
<div class="form-group">
<label for="db_type">Database Type</label>
<select id="db_type" name="db_type">
<option value="sqlite" {% if current_config.db_type == 'sqlite' %}selected{% endif %}>SQLite</option>
<option value="mysql" {% if current_config.db_type == 'mysql' %}selected{% endif %}>MySQL</option>
</select>
</div>
<div id="sqlite_settings" {% if current_config.db_type != 'sqlite' %}style="display: none;"{% endif %}>
<div class="form-group">
<label for="db_sqlite_path">SQLite Database Path</label>
<input type="text" id="db_sqlite_path" name="db_sqlite_path" value="{{ current_config.db_sqlite_path }}">
</div>
</div>
<div id="mysql_settings" {% if current_config.db_type != 'mysql' %}style="display: none;"{% endif %}>
<div class="form-row">
<div class="form-group">
<label for="db_mysql_host">MySQL Host</label>
<input type="text" id="db_mysql_host" name="db_mysql_host" value="{{ current_config.db_mysql_host }}">
</div>
<div class="form-group">
<label for="db_mysql_port">MySQL Port</label>
<input type="number" id="db_mysql_port" name="db_mysql_port" value="{{ current_config.db_mysql_port }}">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="db_mysql_user">MySQL User</label>
<input type="text" id="db_mysql_user" name="db_mysql_user" value="{{ current_config.db_mysql_user }}">
</div>
<div class="form-group">
<label for="db_mysql_password">MySQL Password</label>
<input type="password" id="db_mysql_password" name="db_mysql_password" value="{{ current_config.db_mysql_password }}">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="db_mysql_database">MySQL Database</label>
<input type="text" id="db_mysql_database" name="db_mysql_database" value="{{ current_config.db_mysql_database }}">
</div>
<div class="form-group">
<label for="db_mysql_charset">MySQL Charset</label>
<input type="text" id="db_mysql_charset" name="db_mysql_charset" value="{{ current_config.db_mysql_charset }}">
</div>
</div>
</div>
</div>
<div class="config-section">
<h2 class="section-title">Network Settings</h2>
<div class="form-row">
<div class="form-group">
<label for="web_host">Web Host</label>
<input type="text" id="web_host" name="web_host" value="{{ current_config.web_host }}">
</div>
<div class="form-group">
<label for="web_port">Web Port</label>
<input type="number" id="web_port" name="web_port" value="{{ current_config.web_port }}">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="backend_host">Backend Host</label>
<input type="text" id="backend_host" name="backend_host" value="{{ current_config.backend_host }}">
</div>
<div class="form-group">
<label for="backend_web_port">Backend Web Port</label>
<input type="number" id="backend_web_port" name="backend_web_port" value="{{ current_config.backend_web_port }}">
</div>
<div class="form-group">
<label for="backend_worker_port">Backend Worker Port</label>
<input type="number" id="backend_worker_port" name="backend_worker_port" value="{{ current_config.backend_worker_port }}">
</div>
</div>
<button type="submit" class="btn-submit">Save Configuration</button>
</form>
</div>
......
......@@ -335,43 +335,12 @@ def config():
base_url = request.form.get('base_url', 'http://localhost:5000')
set_base_url(base_url)
# Database
db_type = request.form.get('db_type', 'sqlite')
set_db_type(db_type)
if db_type == 'sqlite':
db_sqlite_path = request.form.get('db_sqlite_path', 'vidai.db')
set_db_sqlite_path(db_sqlite_path)
else:
db_mysql_host = request.form.get('db_mysql_host', 'localhost')
db_mysql_port = int(request.form.get('db_mysql_port', '3306'))
db_mysql_user = request.form.get('db_mysql_user', 'vidai')
db_mysql_password = request.form.get('db_mysql_password', '')
db_mysql_database = request.form.get('db_mysql_database', 'vidai')
db_mysql_charset = request.form.get('db_mysql_charset', 'utf8mb4')
set_db_mysql_config(db_mysql_host, db_mysql_port, db_mysql_user, db_mysql_password, db_mysql_database, db_mysql_charset)
# Network
web_host = request.form.get('web_host', '0.0.0.0')
set_web_host(web_host)
web_port = int(request.form.get('web_port', '5000'))
set_web_port(web_port)
backend_host = request.form.get('backend_host', 'localhost')
set_backend_host(backend_host)
backend_web_port = int(request.form.get('backend_web_port', '5001'))
set_backend_web_port(backend_web_port)
backend_worker_port = int(request.form.get('backend_worker_port', '5002'))
set_backend_worker_port(backend_worker_port)
flash('Configuration updated successfully!', 'success')
# Get all current settings
from .config import get_all_settings
current_config = get_all_settings()
# Get current database settings (runtime changeable)
from .config import get_all_config
current_config = get_all_config()
return render_template('admin/config.html',
user=user,
......
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