Compare commits

...

2 Commits

Author SHA1 Message Date
d519a268a0 Bump version: 1.3.53 → 1.4.0
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 1m33s
2025-07-19 08:56:19 +01:00
e76a54854b config page 2025-07-19 08:56:13 +01:00
6 changed files with 81 additions and 29 deletions

View File

@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "1.3.53"
current_version = "1.4.0"
commit = true
tag = true
tag_name = "{new_version}"

View File

@ -1 +1 @@
1.3.53
1.4.0

20
app.py
View File

@ -298,6 +298,26 @@ def stream_names() -> Union[Response, str]:
return jsonify(get_stream_names(base_url, session["auth_credentials"]))
@app.route('/config', methods=['GET', 'POST'])
def config():
"""Handles access to the configuration page."""
if request.method == 'POST':
password = request.form.get('password')
if password == app.config['CONFIG_PASSWORD']:
session['config_logged_in'] = True
return redirect(url_for('config_dashboard'))
else:
return render_template('config.html', error='Invalid password')
return render_template('config.html')
@app.route('/config/dashboard')
def config_dashboard():
"""Renders the configuration dashboard."""
if not session.get('config_logged_in'):
return redirect(url_for('config'))
return render_template('config_dashboard.html')
if __name__ == "__main__":
app.run(
debug=app.config["DEBUG"],

View File

@ -46,7 +46,7 @@
</main>
<footer class="bg-dark text-white text-center py-3 mt-5">
<p>Version: <a href="#" id="version-link">{{ version }}</a></p>
<p>Version: <a href="{{ url_for('config') }}" style="color: inherit; text-decoration: none;">{{ version }}</a></p>
</footer>
<input type="hidden" id="is-logged-in" value="{{ 'true' if session.get('logged_in') else 'false' }}">
@ -82,32 +82,6 @@
}, function(err) {
console.log('ServiceWorker registration failed: ', err);
});
document.getElementById('version-link').addEventListener('click', function(event) {
event.preventDefault();
fetch('{{ url_for("send_test_notification") }}', {
method: 'POST'
}).then(response => {
console.log('Response status:', response.status);
console.log('Response headers:', response.headers);
return response.text().then(text => {
console.log('Response body:', text);
try {
return JSON.parse(text);
} catch (e) {
console.error('Failed to parse JSON:', e);
throw new Error('Server returned non-JSON response');
}
});
}).then(data => {
console.log('Parsed data:', data);
if (data.message) {
console.log(data.message);
}
}).catch(err => {
console.error('Error sending test notification:', err);
});
});
}
function askPermission(registration) {

27
templates/config.html Normal file
View File

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block title %}Config Access{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3 class="text-center">Enter Password</h3>
</div>
<div class="card-body">
{% if error %}
<div class="alert alert-danger">{{ error }}</div>
{% endif %}
<form method="post" action="{{ url_for('config') }}">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary btn-block">Login</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,31 @@
{% extends "base.html" %}
{% block title %}Config Dashboard{% endblock %}
{% block content %}
<div class="container">
<h2>Configuration Dashboard</h2>
<p>Welcome to the configuration page.</p>
<button id="send-test-notification-btn" class="btn btn-primary">Send Test Notification</button>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script>
document.getElementById('send-test-notification-btn').addEventListener('click', function() {
fetch('{{ url_for("send_test_notification") }}', {
method: 'POST'
}).then(response => {
if (response.ok) {
alert('Test notification sent successfully!');
} else {
alert('Failed to send test notification.');
}
}).catch(err => {
console.error('Error sending test notification:', err);
alert('An error occurred while sending the test notification.');
});
});
</script>
{% endblock %}