feat: copy API key button
This commit is contained in:
parent
8d35123499
commit
720aa62332
@ -16,6 +16,31 @@
|
|||||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css" />
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css" />
|
||||||
<!-- Core theme CSS (includes Bootstrap)-->
|
<!-- Core theme CSS (includes Bootstrap)-->
|
||||||
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />
|
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />
|
||||||
|
<script>
|
||||||
|
function copyToken(token) {
|
||||||
|
if (window.clipboardData && window.clipboardData.setData) {
|
||||||
|
// IE: prevent textarea being shown while dialog is visible
|
||||||
|
return window.clipboardData.setData("Text", token);
|
||||||
|
} else if (document.queryCommandSupported &&
|
||||||
|
document.queryCommandSupported("copy")) {
|
||||||
|
var textarea = document.createElement("textarea");
|
||||||
|
textarea.textContent = token;
|
||||||
|
// Prevent scrolling to bottom of page in MS Edge
|
||||||
|
textarea.style.position = "fixed";
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
try {
|
||||||
|
// Security exception may be thrown by some browsers
|
||||||
|
return document.execCommand("copy");
|
||||||
|
} catch (ex) {
|
||||||
|
console.warn("Copy to clipboard failed.", ex);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Navigation-->
|
<!-- Navigation-->
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
{% block title %}Настройки{% endblock %}
|
{% block title %}Настройки{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h2 class="center-block">Профиль</h2>
|
<h2 class="center-block">Профиль</h2>
|
||||||
|
|
||||||
<p> </p>
|
<p> </p>
|
||||||
@ -43,6 +42,7 @@
|
|||||||
{{ token }}
|
{{ token }}
|
||||||
<form action="{% url 'api_token' %}" method="post">
|
<form action="{% url 'api_token' %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
<input type="button" class="btn btn-primary text-uppercase" onclick="copyToken('{{ token }}')" value="Скопировать"></input>
|
||||||
<input class="btn btn-primary text-uppercase" type="submit" id="resetbutton" value="Сбросить на новый">
|
<input class="btn btn-primary text-uppercase" type="submit" id="resetbutton" value="Сбросить на новый">
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
Loading…
Reference in New Issue
Block a user