extra url modifications
This commit is contained in:
parent
785fdb6dbb
commit
70e7782918
28
app.py
28
app.py
@ -359,6 +359,34 @@ def proxy_dns():
|
|||||||
return jsonify({"error": str(e)}), 502
|
return jsonify({"error": str(e)}), 502
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/extra_urls', methods=['GET', 'POST', 'DELETE'])
|
||||||
|
def proxy_extra_urls():
|
||||||
|
"""Proxies extra URL management requests to the backend."""
|
||||||
|
if not session.get("config_logged_in"):
|
||||||
|
return jsonify({'error': 'Unauthorized'}), 401
|
||||||
|
|
||||||
|
backend_url = f"{app.config['BACKEND_URL']}/extra_urls"
|
||||||
|
credentials = base64.b64decode(session["auth_credentials"]).decode()
|
||||||
|
username, password = credentials.split(":", 1)
|
||||||
|
auth = requests.auth.HTTPBasicAuth(username, password)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if request.method == 'GET':
|
||||||
|
response = requests.get(backend_url, auth=auth)
|
||||||
|
elif request.method == 'POST':
|
||||||
|
response = requests.post(backend_url, auth=auth, json=request.get_json())
|
||||||
|
if response.ok:
|
||||||
|
cache.clear()
|
||||||
|
elif request.method == 'DELETE':
|
||||||
|
response = requests.delete(backend_url, auth=auth, json=request.get_json())
|
||||||
|
if response.ok:
|
||||||
|
cache.clear()
|
||||||
|
|
||||||
|
return Response(response.content, status=response.status_code, mimetype=response.headers['Content-Type'])
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
return jsonify({"error": str(e)}), 502
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(
|
app.run(
|
||||||
debug=app.config["DEBUG"],
|
debug=app.config["DEBUG"],
|
||||||
|
@ -3,35 +3,78 @@
|
|||||||
{% block title %}Config Dashboard{% endblock %}
|
{% block title %}Config Dashboard{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container mt-4">
|
||||||
<h2>Configuration Dashboard</h2>
|
<h2 class="mb-4">Configuration Dashboard</h2>
|
||||||
<p>Welcome to the configuration page.</p>
|
|
||||||
<button id="send-test-notification-btn" class="btn btn-primary">Send Test Notification</button>
|
|
||||||
<button id="check-expiring-accounts-btn" class="btn btn-info">Check Expiring Accounts</button>
|
|
||||||
|
|
||||||
<div class="card mt-4">
|
<div class="row">
|
||||||
<div class="card-header">
|
<div class="col-md-12">
|
||||||
DNS Manager
|
<div class="card">
|
||||||
</div>
|
<div class="card-header">
|
||||||
<div class="card-body">
|
Actions
|
||||||
<div class="input-group mb-3">
|
</div>
|
||||||
<input type="text" class="form-control" id="dns-entry-input" placeholder="Enter DNS entry">
|
<div class="card-body">
|
||||||
<div class="input-group-append">
|
<button id="send-test-notification-btn" class="btn btn-primary">Send Test Notification</button>
|
||||||
<button class="btn btn-primary" id="add-dns-btn">Add</button>
|
<button id="check-expiring-accounts-btn" class="btn btn-info">Check Expiring Accounts</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
DNS Manager
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" class="form-control" id="dns-entry-input" placeholder="Enter DNS entry">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-primary" id="add-dns-btn">Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>DNS Entry</th>
|
||||||
|
<th style="width: 10%;">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="dns-list-table-body">
|
||||||
|
<!-- DNS entries will be loaded here -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
Extra URLs Manager
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" class="form-control" id="extra-url-input" placeholder="Enter Extra URL">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-primary" id="add-extra-url-btn">Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Extra URL</th>
|
||||||
|
<th style="width: 10%;">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="extra-urls-table-body">
|
||||||
|
<!-- Extra URLs will be loaded here -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-striped mt-3">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>DNS Entry</th>
|
|
||||||
<th style="width: 10%;">Actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="dns-list-table-body">
|
|
||||||
<!-- DNS entries will be loaded here -->
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -123,6 +166,69 @@
|
|||||||
addDnsBtn.addEventListener('click', addDnsEntry);
|
addDnsBtn.addEventListener('click', addDnsEntry);
|
||||||
fetchDnsList();
|
fetchDnsList();
|
||||||
|
|
||||||
|
// Extra URLs Manager
|
||||||
|
const extraUrlsTableBody = document.getElementById('extra-urls-table-body');
|
||||||
|
const addExtraUrlBtn = document.getElementById('add-extra-url-btn');
|
||||||
|
const extraUrlInput = document.getElementById('extra-url-input');
|
||||||
|
|
||||||
|
function fetchExtraUrlsList() {
|
||||||
|
fetch("{{ url_for('proxy_extra_urls') }}")
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
extraUrlsTableBody.innerHTML = '';
|
||||||
|
if (data.length === 0) {
|
||||||
|
const row = extraUrlsTableBody.insertRow();
|
||||||
|
const cell = row.insertCell();
|
||||||
|
cell.colSpan = 2;
|
||||||
|
cell.textContent = 'No extra URLs found.';
|
||||||
|
cell.classList.add('text-center');
|
||||||
|
} else {
|
||||||
|
data.forEach(entry => {
|
||||||
|
const row = extraUrlsTableBody.insertRow();
|
||||||
|
const entryCell = row.insertCell();
|
||||||
|
entryCell.textContent = entry;
|
||||||
|
const actionCell = row.insertCell();
|
||||||
|
const removeBtn = document.createElement('button');
|
||||||
|
removeBtn.className = 'btn btn-danger btn-sm';
|
||||||
|
removeBtn.textContent = 'Delete';
|
||||||
|
removeBtn.addEventListener('click', () => removeExtraUrl(entry));
|
||||||
|
actionCell.appendChild(removeBtn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addExtraUrl() {
|
||||||
|
const extraUrl = extraUrlInput.value.trim();
|
||||||
|
if (extraUrl) {
|
||||||
|
fetch("{{ url_for('proxy_extra_urls') }}", {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ extra_url: extraUrl })
|
||||||
|
}).then(() => {
|
||||||
|
extraUrlInput.value = '';
|
||||||
|
fetchExtraUrlsList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeExtraUrl(extraUrl) {
|
||||||
|
fetch("{{ url_for('proxy_extra_urls') }}", {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ extra_url: extraUrl })
|
||||||
|
}).then(() => {
|
||||||
|
fetchExtraUrlsList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addExtraUrlBtn.addEventListener('click', addExtraUrl);
|
||||||
|
fetchExtraUrlsList();
|
||||||
|
|
||||||
// Other buttons
|
// Other buttons
|
||||||
document.getElementById('send-test-notification-btn').addEventListener('click', function() {
|
document.getElementById('send-test-notification-btn').addEventListener('click', function() {
|
||||||
fetch('{{ url_for("send_test_notification") }}', {
|
fetch('{{ url_for("send_test_notification") }}', {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user