1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
hSaria 298152bc50 Closes #2638: Copy Button for Secrets (#2860)
* Added clipboard.min.js

* Added copy button to secrets

* renamed clipboard JS library
2019-02-21 13:26:19 -05:00

111 lines
4.4 KiB
HTML

{% extends '_base.html' %}
{% load static %}
{% load helpers %}
{% load secret_helpers %}
{% block header %}
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
<li><a href="{% url 'secrets:secret_list' %}">Secrets</a></li>
<li><a href="{% url 'secrets:secret_list' %}?role={{ secret.role.slug }}">{{ secret.role }}</a></li>
<li>{{ secret.device }}{% if secret.name %} ({{ secret.name }}){% endif %}</li>
</ol>
</div>
</div>
<div class="pull-right">
{% if perms.secrets.change_secret %}
<a href="{% url 'secrets:secret_edit' pk=secret.pk %}" class="btn btn-warning">
<span class="fa fa-pencil" aria-hidden="true"></span>
Edit this secret
</a>
{% endif %}
{% if perms.secrets.delete_secret %}
<a href="{% url 'secrets:secret_delete' pk=secret.pk %}" class="btn btn-danger">
<span class="fa fa-trash" aria-hidden="true"></span>
Delete this secret
</a>
{% endif %}
</div>
<h1>{% block title %}{{ secret }}{% endblock %}</h1>
{% include 'inc/created_updated.html' with obj=secret %}
<ul class="nav nav-tabs">
<li role="presentation"{% if not active_tab %} class="active"{% endif %}>
<a href="{{ secret.get_absolute_url }}">Secret</a>
</li>
<li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
<a href="{% url 'secrets:secret_changelog' pk=secret.pk %}">Changelog</a>
</li>
</ul>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Secret Attributes</strong>
</div>
<table class="table table-hover panel-body">
<tr>
<td>Device</td>
<td>
<a href="{% url 'dcim:device' pk=secret.device.pk %}">{{ secret.device }}</a>
</td>
</tr>
<tr>
<td>Role</td>
<td>{{ secret.role }}</td>
</tr>
<tr>
<td>Name</td>
<td>{{ secret.name|placeholder }}</td>
</tr>
</table>
</div>
{% include 'inc/custom_fields_panel.html' with obj=secret %}
</div>
<div class="col-md-6">
{% if secret|decryptable_by:request.user %}
<div class="panel panel-default">
<div class="panel-heading">
<strong>Secret Data</strong>
</div>
<div class="panel-body">
<form id="secret_form">
{% csrf_token %}
</form>
<div class="row">
<div class="col-md-2">Secret</div>
<div class="col-md-6" id="secret_{{ secret.pk }}">********</div>
<div class="col-md-4 text-right">
<button class="btn btn-xs btn-success unlock-secret" secret-id="{{ secret.pk }}">
<i class="fa fa-lock"></i> Unlock
</button>
<button class="btn btn-xs btn-default copy-secret collapse" secret-id="{{ secret.pk }}" data-clipboard-target="#secret_{{ secret.pk }}">
<i class="fa fa-copy"></i> Copy
</button>
<button class="btn btn-xs btn-danger lock-secret collapse" secret-id="{{ secret.pk }}">
<i class="fa fa-unlock-alt"></i> Lock
</button>
</div>
</div>
</div>
</div>
{% else %}
<div class="alert alert-warning">
<i class="fa fa-warning" aria-hidden="true"></i>
You do not have permission to decrypt this secret.
</div>
{% endif %}
{% include 'extras/inc/tags_panel.html' with tags=secret.tags.all url='secrets:secret_list' %}
</div>
</div>
{% include 'secrets/inc/private_key_modal.html' %}
{% endblock %}
{% block javascript %}
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
{% endblock %}