add create snapshot now button

This commit is contained in:
simon 2022-10-31 21:21:28 +07:00
parent 01a8c65df9
commit 476d4d4909
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 11 additions and 2 deletions

View File

@ -162,10 +162,10 @@
</div> </div>
<div> <div>
{% if snapshots %} {% if snapshots %}
<p>Create next snapshot: <span class="settings-current">{{ snapshots.next_exec_str }}</span>, snapshots expire after <span class="settings-current">{{ snapshots.expire_after }}</span></p> <p>Create next snapshot: <span class="settings-current">{{ snapshots.next_exec_str }}</span>, snapshots expire after <span class="settings-current">{{ snapshots.expire_after }}</span>. <button onclick="createSnapshot()" id="createButton">Create snapshot now</button></p>
<br> <br>
{% for snapshot in snapshots.snapshots %} {% for snapshot in snapshots.snapshots %}
<p><button id="{{ snapshot.id }}" onclick="restoreSnapshot(id)">Restore</button> Snapshot created on: <span class="settings-current">{{ snapshot.start_date }}</span>, took <span class="settings-current">{{ snapshot.duration_s }}s</span> to create.</p> <p><button id="{{ snapshot.id }}" onclick="restoreSnapshot(id)">Restore</button> Snapshot created on: <span class="settings-current">{{ snapshot.start_date }}</span>, took <span class="settings-current">{{ snapshot.duration_s }}s</span> to create. State: <i>{{ snapshot.state }}</i></p>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>

View File

@ -297,6 +297,15 @@ function restoreSnapshot(snapshotId) {
document.getElementById(snapshotId).parentElement.replaceWith(message); document.getElementById(snapshotId).parentElement.replaceWith(message);
} }
function createSnapshot() {
console.log('create snapshot now');
let apiEndpoint = '/api/snapshot/';
apiRequest(apiEndpoint, 'POST');
let message = document.createElement('span');
message.innerText = 'Snapshot in progress';
document.getElementById('createButton').replaceWith(message);
}
// delete from file system // delete from file system
function deleteConfirm() { function deleteConfirm() {
let to_show = document.getElementById('delete-button'); let to_show = document.getElementById('delete-button');