Skip to content

Commit

Permalink
updated html and mapping
Browse files Browse the repository at this point in the history
updated mapping and html so that the forward is identified by the old value and not a key
  • Loading branch information
agmes4 authored and lukasjuhrich committed Nov 1, 2023
1 parent e531a93 commit 2f8507c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
10 changes: 7 additions & 3 deletions sipa/blueprints/usersuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,14 +652,18 @@ def get_edit(port_forward: int):
return render_template("usersuite/_get_port_row.html", edit=True, port_index=port_forward, port_forwarding=port_forwarding, form=AddPortForwardForm())


@bp_usersuite.route("/get_row", methods=['GET'])
@bp_usersuite.route("/get_row", methods=['GET', 'POST'])
@login_required
def get_new_portforward():
"""
Returns the template for a new port forwarding
"""
port_forwarding = None
return render_template("usersuite/_get_port_row.html", port_forwarding=port_forwarding, form=AddPortForwardForm())
if request.method == 'POST':
port_forwarding = AddPortForwardForm(request.form).get_list()
else:
port_forwarding = None

return render_template("usersuite/_get_port_row.html", port_forwarding=port_forwarding, form=AddPortForwardForm(), edit=True)


@bp_usersuite.route("/port-forward-edit/<int:port_index>", methods=['PUT', 'POST'])
Expand Down
29 changes: 22 additions & 7 deletions sipa/templates/usersuite/_get_port_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
<td>
<input type="number" min="1" name="source_port" hx-post="/control/port" hx-trigger="change" hx-target="next .error-label" hx-swap="innerHTML" value="{{ port_forwarding[0] }}">
<label class='error-label' for="source_port"></label>
<input name="old_source_port" value="{{ port_forwarding[0] }}" hidden="">
</td>
<td>
<input type="number" min="1" name="dest_port" hx-post="/control/port" hx-target="next .error-label" hx-swap="innerHTML" value="{{ port_forwarding[1] }}">
<label class='error-label' for="dest_port"></label>
<td>
<input type="number" min="1" name="dest_port" hx-post="/control/port" hx-target="next .error-label" hx-swap="innerHTML" value="{{ port_forwarding[1] }}">
<label class='error-label' for="dest_port"></label>
<input name="old_dest_port" type="number" value="{{ port_forwarding[1] }}" hidden="">
</td>
<td><input type="text" name="ip_address" placeholder="source ip" hx-post="/control/ip" value="{{ port_forwarding[2] }}"></td>
<td>
<input type="text" name="ip_address" placeholder="source ip" hx-post="/control/ip" value="{{ port_forwarding[2] }}">
<input name="old_ip_address" value="{{ port_forwarding[2] }}" hidden="">
</td>
<td>
<label for="udp">UDP</label>
<input type="radio" name="prot" value="udp" {% if port_forwarding[3] =="UDP" %}checked{% endif %}>
Expand All @@ -30,19 +35,29 @@

</tr >
{% else %}
<tr >
<tr>
<form>

<td>
<label>{{ port_forwarding[0] }}</label>
<input name="source_port" value="{{ port_forwarding[0] }}" hidden="">
</td>
<td>
<label >{{ port_forwarding[1] }}</label>
<input name="dest_port" type="number" value="{{ port_forwarding[1] }}" hidden="">
</td>
<td>
<label >{{ port_forwarding[2] }}</label>
<input name="ip_address" value="{{ port_forwarding[2] }}" hidden="">
</td>
<td><label >{{ port_forwarding[2] }}</label></td>

<td>
<label>{{ port_forwarding[3] }}</label>
<input name="prot" type="radio" value="{{ port_forwarding[3] }}" checked hidden="">
</td>
</form>
<td>
<button class="edit-button edit-pen" aria-label="edit" hx-get="/usersuite/get_row/{{ port_index }}" hx-target="closest tr" hx-swap="outerHTML swap:500ms">
<button class="edit-button edit-pen" aria-label="edit" hx-post="/usersuite/get_row" hx-include="closest tr" hx-target="closest tr" hx-swap="outerHTML swap:500ms">
<span class="glyphicon glyphicon-pencil pull-left"></span>
</button>
<button class="edit-button error-label" hx-confirm="{{ _("wollen sie die port Weiterleitung wirklich löschen?") }}" hx-delete="/usersuite/port-forward/{{ port_index }}" hx-target="closest tr">
Expand Down

0 comments on commit 2f8507c

Please sign in to comment.