Added next button in order detail view after the user make a payment, Avoid to regenerate SSH Key if the user refresh the page, Now the key is served to download from javascript , Added public_key attribute to VirtualVMPlan in order to store keys created by the user, Now private key has PEM format and public has OpenSSH
This commit is contained in:
parent
35e312411f
commit
b4164e56ab
7 changed files with 140 additions and 33 deletions
|
|
@ -163,6 +163,9 @@
|
|||
<!-- Proccess payment lib -->
|
||||
<script type="text/javascript" src="{% static 'hosting/js/payment.js' %}"></script>
|
||||
|
||||
<!-- Gen SSH Key lib -->
|
||||
<script type="text/javascript" src="{% static 'hosting/js/gen-ssh-key.js' %}"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -58,7 +58,13 @@
|
|||
<hr>
|
||||
<h4>Total<p class="pull-right"><b>{{order.vm_plan.price}} CHF</b></p></h4>
|
||||
</div>
|
||||
<a href="{% url 'hosting:virtual_machines' order.vm_plan.id %}" class="pull-right"><button class="btn-info">View instance</button></a>
|
||||
<br/>
|
||||
{% url 'hosting:payment' as payment_url %}
|
||||
{% if payment_url in request.META.HTTP_REFERER %}
|
||||
<div class=" content pull-right">
|
||||
<a href="{% url 'hosting:virtual_machine_key' order.vm_plan.id %}" ><button class="btn btn-info">Finish Configuration</button></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,25 +6,58 @@
|
|||
<div class="row">
|
||||
<div class="col-md-9 col-md-offset-2">
|
||||
<div class="col-sm-12">
|
||||
<h3><i class="fa fa-key" aria-hidden="true"></i> Private Key</h3>
|
||||
|
||||
<h3><i class="fa fa-key" aria-hidden="true"></i> SSH Private Key</h3>
|
||||
<hr/>
|
||||
{% if private_key %}
|
||||
<div class="alert alert-warning">
|
||||
<strong>Warning!</strong> You can view your SSH private key once. Copy it or if it wasn't downloaded automatically, just click on Download to start it.
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="comment">private_key.pem</label>
|
||||
<textarea class="form-control" rows="8" id="ssh_key">{{private_key}}</textarea>
|
||||
<span class="h3 pull-right"><button type="button" class="btn btn-default"><a href=""> Download </a></button></span>
|
||||
<span class="h3 pull-right"><button type="button" data-clipboard-target="#ssh_key" class="btn btn-default">Copy to Clipboard</button></span>
|
||||
<textarea class="form-control" rows="6" id="ssh_key">{{private_key}}</textarea>
|
||||
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group pull-right">
|
||||
<button type="button" id="copy_to_clipboard" data-clipboard-target="#ssh_key" class="btn btn-warning"
|
||||
data-toggle="tooltip" data-placement="bottom" title="Copied" data-trigger="click">Copy to Clipboard</button>
|
||||
<button type="button" id="download_ssh_key" class="btn btn-warning">Download</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-warning">
|
||||
<strong>Warning!</strong> Your SSH private key was already generated and downloaded, if you lost it, contact us.
|
||||
</div>
|
||||
{% endif %}
|
||||
<a class="btn btn-success" href="{% url 'hosting:virtual_machines' virtual_machine.id %}"> Go to my Virtual Machine Dashboard</a>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if private_key %}
|
||||
<!-- Force to download ssh key on page load -->
|
||||
<script type="text/javascript">
|
||||
(function () {new Clipboard('.btn');})();
|
||||
|
||||
var key = window.document.getElementById('ssh_key');
|
||||
var a = window.document.createElement('a');
|
||||
|
||||
a.href = window.URL.createObjectURL(new Blob(['key'], {type: 'text'}));
|
||||
a.download = 'private_key.pem';
|
||||
|
||||
// Append anchor to body.
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
// Remove anchor from body
|
||||
document.body.removeChild(a);
|
||||
|
||||
</script>
|
||||
{%endif%}
|
||||
|
||||
|
||||
{%endblock%}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue