diff --git a/app/templates/_helpers.html b/app/templates/_helpers.html index acc9431f8f88e63ea25cde383e5902d6f56cd26e..3508eaa3a0df76b5d1fc2913a3b5fae38e9b782b 100644 --- a/app/templates/_helpers.html +++ b/app/templates/_helpers.html @@ -43,3 +43,26 @@ {% macro format_datetime(dt) -%} {{ dt.strftime("%Y-%m-%d %H:%M") }} {%- endmacro %} + +{% macro delete_button_with_confirmation(title, modal_id, message) -%} + <button type="button" class="btn btn-light" data-toggle="modal" data-target={{ "#%s" | format(modal_id) }}> + <span class="oi oi-trash" title="{{ title }}" aria-hidden="true"></span> + </button> + <!-- Modal --> + <div class="modal fade" id="{{ modal_id }}" tabindex="-1" role="dialog" aria-labelledby="delete-confirmation" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h6 class="modal-title">{{ message }}</h6> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> + <button type="submit" class="btn btn-primary">OK</button> + </div> + </div> + </div> + </div> +{%- endmacro %} diff --git a/app/templates/network/view_host.html b/app/templates/network/view_host.html index 38efba32e2c16bcf6fda6d1d590060c0fb89438b..50ae3f96d71768616c5308fe132bfba952e288fc 100644 --- a/app/templates/network/view_host.html +++ b/app/templates/network/view_host.html @@ -1,5 +1,5 @@ {% extends "network/hosts.html" %} -{% from "_helpers.html" import link_to_item %} +{% from "_helpers.html" import link_to_item, delete_button_with_confirmation %} {% block title %}View Host - CSEntry{% endblock %} @@ -50,9 +50,8 @@ </a> <form method="POST" action="/network/interfaces/delete"> <input id="interface_id" name="interface_id" type="hidden" value="{{ interface.id }}"> - <button type="submit" class="btn btn-light"> - <span class="oi oi-trash" title="Delete interface" aria-hidden="true"></span> - </button> + {{ delete_button_with_confirmation("Delete interface", "deleteConfirmation-%s" | format(interface.id), + "Are you sure you want to delete interface %s?" | format(interface.name)) }} </form> </td> <td>{{ interface.name }}</td> diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index 58f2ac6df93e03184cf9f38d8277aa7010d9f97c..0eb3c463f100073b9e68e45dca2c9a0b94a2c975 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% from "_helpers.html" import render_field %} +{% from "_helpers.html" import render_field, delete_button_with_confirmation %} {% block title %}Profile - CSEntry{% endblock %} @@ -50,9 +50,8 @@ <form method="POST" action="/users/tokens/revoke"> <input id="token_id" name="token_id" type="hidden" value="{{ token.id }}"> <input id="jti" name="jti" type="hidden" value="{{ token.jti }}"> - <button type="submit" class="btn btn-danger"> - <span class="oi oi-trash" title="Revoke token" aria-hidden="true"></span> - </button> + {{ delete_button_with_confirmation("Revoke token", "revokeConfirmation-%s" | format(token.id), + "Are you sure you want to revoke token %s?" | format(token.jti)) }} </form> </td> <td>{{ token.jti }}</td>