frontend API button to restore snapshot

This commit is contained in:
simon 2022-10-29 20:12:54 +07:00
parent fb25b76950
commit b425e7d75c
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 11 additions and 1 deletions

View File

@ -165,7 +165,7 @@
<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>
<br>
{% for snapshot in snapshots.snapshots %}
<p><button data-id="{{ snapshot.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.</p>
{% endfor %}
{% endif %}
</div>

View File

@ -287,6 +287,16 @@ function resetToken() {
document.getElementById('text-reveal').replaceWith(message);
}
// restore from snapshot
function restoreSnapshot(snapshotId) {
console.log('restore ' + snapshotId);
let apiEndpoint = '/api/snapshot/' + snapshotId + '/';
apiRequest(apiEndpoint, 'POST');
let message = document.createElement('p');
message.innerText = 'Snapshot restore started';
document.getElementById(snapshotId).parentElement.replaceWith(message);
}
// delete from file system
function deleteConfirm() {
let to_show = document.getElementById('delete-button');