Skip to content

Commit

Permalink
Merge pull request #130 from thalesgroup-cert/v2
Browse files Browse the repository at this point in the history
Update pop-up after API Key creation
  • Loading branch information
ygalnezri authored Jun 26, 2024
2 parents 3dee1e1 + a58da29 commit 36bde0c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Watcher/Watcher/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def save_model(self, request, obj, form, change):
<img src="https://img.icons8.com/material-outlined/24/000000/clipboard.png" alt="Copy" style="vertical-align: middle;"/>
<span style="vertical-align: middle;">Copy</span>
</button>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script>
function copyToClipboard(text) {{
const textarea = document.createElement('textarea');
Expand All @@ -291,9 +292,26 @@ def save_model(self, request, obj, form, change):
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
alert('API key copied to clipboard');
Swal.fire({{
position: 'bottom-end',
icon: 'success',
title: 'Copied!',
text: 'API key copied to clipboard',
showConfirmButton: false,
timer: 3000,
customClass: {{
popup: 'small-swal-popup'
}}
}});
}}
</script>
<style>
.small-swal-popup {{
width: 300px !important;
padding: 10px !important;
font-size: 12px !important;
}}
</style>
'''
messages.success(request, mark_safe(f"The API Key for {user.username} was added successfully: {raw_key}. {copy_button} Make sure to copy this personal token now. You won't be able to see it again!"), extra_tags='safe', fail_silently=True)
super().save_model(request, obj, form, change)
Expand Down

0 comments on commit 36bde0c

Please sign in to comment.