summaryrefslogtreecommitdiffstats
path: root/ogcp/templates/actions
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-03 12:45:49 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-03 16:26:22 +0200
commit7613cd8017e978e771552467a4e10141e120fccb (patch)
tree172c69df30ead92bdf6b9fb2619523ad6b4f9f29 /ogcp/templates/actions
parentc1ac88e47c8562699edc9f5304649762366191e0 (diff)
ogcp: add server ip configuration
Enable server view in the main toolbar. Hide Add server and Delete server buttons. Add Update server button. Add server/update view to edit the server addresses.
Diffstat (limited to 'ogcp/templates/actions')
-rw-r--r--ogcp/templates/actions/server_update.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/ogcp/templates/actions/server_update.html b/ogcp/templates/actions/server_update.html
new file mode 100644
index 0000000..ae2513b
--- /dev/null
+++ b/ogcp/templates/actions/server_update.html
@@ -0,0 +1,69 @@
+{% extends 'servers.html' %}
+{% import "bootstrap/wtf.html" as wtf %}
+
+{% set sidebar_state = 'disabled' %}
+{% set btn_back = true %}
+
+{% block nav_server_add %}active{% endblock %}
+{% block content %}
+
+<h2 class="mx-5 subhead-heading">{{_('Update server')}}</h2>
+
+<form class="form mx-5" method="POST">
+ {{ form.hidden_tag() }}
+
+ {{ form.server_addr() }}
+
+ <div class="form-group">
+ <div id="ip-fields">
+ {% for addr in form.addr %}
+ <div class="d-flex align-items-center mb-2">
+ {{ addr(class="form-control me-2", placeholder=_("Enter IP Address"), required=True) }}
+ <button type="button" class="btn btn-danger" onclick="removeIPField(this)">{{_('Remove') }}</button>
+ </div>
+ {% endfor %}
+ </div>
+ <button type="button" class="btn btn-primary" onclick="addIPField()">{{_('Add address') }}</button>
+
+ {{ form.submit(class="btn btn-success") }}
+ </div>
+</form>
+
+<script>
+ function addIPField() {
+ const container = document.createElement('div');
+ container.classList.add('d-flex', 'align-items-center', 'mb-2');
+
+ const newField = document.createElement('input');
+ newField.setAttribute('type', 'text');
+ newField.setAttribute('name', 'addr-' + document.querySelectorAll('input[name^="addr-"]').length);
+ newField.classList.add('form-control', 'me-2');
+ newField.setAttribute('placeholder', '{{ _('Enter IP Address') }}');
+ newField.required = true;
+
+ const removeButton = document.createElement('button');
+ removeButton.setAttribute('type', 'button');
+ removeButton.classList.add('btn', 'btn-danger');
+ removeButton.innerText = '{{ _('Remove') }}';
+ removeButton.onclick = function() {
+ removeIPField(this);
+ };
+
+ container.appendChild(newField);
+ container.appendChild(removeButton);
+ document.getElementById('ip-fields').appendChild(container);
+ }
+
+ function removeIPField(elem) {
+ const ipFieldsContainer = document.getElementById('ip-fields');
+ const ipFieldDivs = ipFieldsContainer.querySelectorAll('.d-flex');
+
+ if (ipFieldDivs.length <= 1) {
+ return;
+ }
+ const parentDiv = elem.parentElement;
+ parentDiv.remove();
+ }
+</script>
+
+{% endblock %}