This commit is contained in:
2025-03-12 15:46:32 +02:00
parent 2b1ba88811
commit fec6b90993
3 changed files with 18 additions and 4 deletions

View File

@@ -31,6 +31,13 @@ class Log(db.Model):
mission3 = db.Column(db.String(100), default='')
mission4 = db.Column(db.String(100), default='')
class MirServerSettings(db.Model):
id = db.Column(db.Integer, primary_key=True)
ip_address = db.Column(db.String(100), nullable=False)
user = db.Column(db.String(100), nullable=False)
password = db.Column(db.String(100), nullable=False)
auth_header = db.Column(db.String(500), nullable=False)
# Create the database if it does not exist
if not os.path.exists('instance/logs.db'):
with app.app_context():
@@ -215,6 +222,7 @@ def settings():
mir_ip = app.config.get('MIR_IP', '')
mir_user = app.config.get('MIR_USER', '')
mir_password = app.config.get('MIR_PASSWORD', '')
mir_auth_header = app.config.get('MIR_AUTH_HEADER', '')
boards = Log.query.with_entities(Log.hostname).distinct().all()
board_settings = []
for board in boards:
@@ -230,7 +238,7 @@ def settings():
'mission3': latest_log.mission3 if latest_log else '',
'mission4': latest_log.mission4 if latest_log else ''
})
return render_template('settings.html', cleanup_time=cleanup_time, mir_ip=mir_ip, mir_user=mir_user, mir_password=mir_password, boards=board_settings)
return render_template('settings.html', cleanup_time=cleanup_time, mir_ip=mir_ip, mir_user=mir_user, mir_password=mir_password, mir_auth_header=mir_auth_header, boards=board_settings)
@app.route('/set_cleanup_time', methods=['POST'])
def set_cleanup_time():
@@ -247,13 +255,15 @@ def set_mir_server():
mir_ip = request.form.get('mir_ip')
mir_user = request.form.get('mir_user')
mir_password = request.form.get('mir_password')
if mir_ip and mir_user and mir_password:
mir_auth_header = request.form.get('mir_auth_header')
if mir_ip and mir_user and mir_password and mir_auth_header:
app.config['MIR_IP'] = mir_ip
app.config['MIR_USER'] = mir_user
app.config['MIR_PASSWORD'] = mir_password
flash('MIR server settings updated successfully!', 'success')
app.config['MIR_AUTH_HEADER'] = mir_auth_header
flash('MIR Server settings updated successfully!', 'success')
else:
flash('Invalid MIR server settings!', 'danger')
flash('Invalid MIR Server settings!', 'danger')
return redirect(url_for('settings'))
@app.route('/set_board_settings/<hostname>', methods=['POST'])

Binary file not shown.

View File

@@ -79,6 +79,10 @@
<label for="mir_password">MIR Server Password:</label>
<input type="password" class="form-control" id="mir_password" name="mir_password" value="{{ mir_password }}" required>
</div>
<div class="form-group">
<label for="mir_auth_header">Authorization Header:</label>
<input type="text" class="form-control" id="mir_auth_header" name="mir_auth_header" value="{{ mir_auth_header }}" required>
</div>
<button type="submit" class="btn btn-primary">Set MIR Server</button>
</form>
</div>