From 476d4d4909e8e62a7988021acb2158a889f27a5d Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 31 Oct 2022 21:21:28 +0700 Subject: [PATCH] add create snapshot now button --- tubearchivist/home/templates/home/settings.html | 4 ++-- tubearchivist/static/script.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index 999834fa..b1aed64c 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -162,10 +162,10 @@
{% if snapshots %} -

Create next snapshot: {{ snapshots.next_exec_str }}, snapshots expire after {{ snapshots.expire_after }}

+

Create next snapshot: {{ snapshots.next_exec_str }}, snapshots expire after {{ snapshots.expire_after }}.


{% for snapshot in snapshots.snapshots %} -

Snapshot created on: {{ snapshot.start_date }}, took {{ snapshot.duration_s }}s to create.

+

Snapshot created on: {{ snapshot.start_date }}, took {{ snapshot.duration_s }}s to create. State: {{ snapshot.state }}

{% endfor %} {% endif %}
diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index ee2dc12d..8a98092b 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -297,6 +297,15 @@ function restoreSnapshot(snapshotId) { 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 function deleteConfirm() { let to_show = document.getElementById('delete-button');