Invert content of settings and configuration pages

parent e16ed66a
......@@ -91,15 +91,31 @@
<form method="post" action="/update_settings">
<div class="form-group">
<label for="default_model">Default AI Model</label>
<input type="text" id="default_model" name="default_model" value="Qwen/Qwen2.5-VL-7B-Instruct" placeholder="Model path or HuggingFace ID">
<label for="analysis_backend">Analysis Backend:</label>
<select name="analysis_backend" id="analysis_backend">
{% if 'cuda' in available_backends %}
<option value="cuda" {% if current_config.get('analysis_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('analysis_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select>
</div>
<div class="form-group">
<label for="theme">Theme Preference</label>
<select id="theme" name="theme">
<option value="light" selected>Light</option>
<option value="dark">Dark</option>
<label for="training_backend">Training Backend:</label>
<select name="training_backend" id="training_backend">
{% if 'cuda' in available_backends %}
<option value="cuda" {% if current_config.get('training_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('training_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select>
</div>
......
......@@ -36,33 +36,18 @@
<h1 class="config-title">Configuration</h1>
<form method="post" class="config-form">
<div class="form-group">
<label for="analysis_backend">Analysis Backend:</label>
<select name="analysis_backend" id="analysis_backend">
{% if 'cuda' in available_backends %}
<option value="cuda" {% if current_config.get('analysis_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('analysis_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select>
<label for="default_model">Default AI Model</label>
<input type="text" id="default_model" name="default_model" value="Qwen/Qwen2.5-VL-7B-Instruct" placeholder="Model path or HuggingFace ID">
</div>
<div class="form-group">
<label for="training_backend">Training Backend:</label>
<select name="training_backend" id="training_backend">
{% if 'cuda' in available_backends %}
<option value="cuda" {% if current_config.get('training_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('training_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
<label for="theme">Theme Preference</label>
<select id="theme" name="theme">
<option value="light" selected>Light</option>
<option value="dark">Dark</option>
</select>
</div>
<button type="submit" class="btn-submit">Save Configuration</button>
</form>
</div>
......
......@@ -280,18 +280,33 @@ def settings():
"""Admin settings page."""
user = get_current_user_session()
# Get current config
from .config import get_analysis_backend, get_training_backend
current_config = {
'analysis_backend': get_analysis_backend(),
'training_backend': get_training_backend()
}
# Get available backends
from .compat import get_available_backends
available_backends = get_available_backends()
return render_template('admin/settings.html',
user=user,
tokens=get_user_tokens(user["id"]),
current_config=current_config,
available_backends=available_backends,
active_page='settings')
@admin_bp.route('/update_settings', methods=['POST'])
@admin_required
def update_settings():
"""Update admin settings."""
# For now, just flash a success message
# In a real implementation, this would save admin preferences
from flask import flash
from .config import set_analysis_backend, set_training_backend
analysis_backend = request.form.get('analysis_backend', 'cuda')
training_backend = request.form.get('training_backend', 'cuda')
set_analysis_backend(analysis_backend)
set_training_backend(training_backend)
flash('Settings updated successfully!', 'success')
return redirect(url_for('admin.settings'))
......
......@@ -269,24 +269,21 @@ def analyze():
@app.route('/config', methods=['GET', 'POST'])
def config():
if request.method == 'POST':
data = {
'analysis_backend': request.form.get('analysis_backend', 'cuda'),
'training_backend': request.form.get('training_backend', 'cuda')
}
msg_id = send_to_backend('config_update', data)
result_data = get_result(msg_id)
status = result_data.get('data', {}).get('status', 'Error')
from .config import set_default_model, set_default_model_type
default_model = request.form.get('default_model', 'Qwen/Qwen2.5-VL-7B-Instruct')
theme = request.form.get('theme', 'light')
set_default_model(default_model)
# For theme, perhaps store it somewhere, but for now, just flash
flash('Configuration updated successfully!', 'success')
# Get current config
msg_id = send_to_backend('get_config', {})
config_data = get_result(msg_id)
current_config = config_data.get('data', {})
from .config import get_default_model
current_config = {
'default_model': get_default_model(),
'theme': 'light' # Default
}
# Get available backends
from .compat import get_available_backends
available_backends = get_available_backends()
return render_template('config.html', current_config=current_config, available_backends=available_backends, active_page='config', user=None)
return render_template('config.html', current_config=current_config, available_backends=[], active_page='config', user=None)
@app.route('/history')
@login_required
......@@ -306,8 +303,11 @@ def history():
@login_required
def update_settings():
"""Update user settings."""
# For now, just flash a success message
# In a real implementation, this would save user preferences
from .config import set_analysis_backend, set_training_backend
analysis_backend = request.form.get('analysis_backend', 'cuda')
training_backend = request.form.get('training_backend', 'cuda')
set_analysis_backend(analysis_backend)
set_training_backend(training_backend)
flash('Settings updated successfully!', 'success')
return redirect(url_for('settings'))
......
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