mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-22 17:22:58 +01:00
🔨 Edit frontend for Restore function
This commit is contained in:
parent
2c506c2e69
commit
88cd6f2c45
@ -1,7 +1,7 @@
|
|||||||
<% if (locals.backups) { %>
|
<% if (locals.backups) { %>
|
||||||
<div class="collection">
|
<div class="collection">
|
||||||
<% for(const index in backups) { %>
|
<% for(const index in backups) { %>
|
||||||
<a class="collection-item local-snap-listener modal-trigger" href="#modal-<%=backups[index].etag%>"
|
<a class="collection-item modal-trigger" href="#modal-<%=backups[index].etag%>"
|
||||||
data-id="<%= backups[index].etag %>">
|
data-id="<%= backups[index].etag %>">
|
||||||
<div><%= backups[index].basename%><div class="secondary-content hide-on-small-and-down">
|
<div><%= backups[index].basename%><div class="secondary-content hide-on-small-and-down">
|
||||||
<%= moment(backups[index].lastmod).format('MMM D, YYYY HH:mm') %></div>
|
<%= moment(backups[index].lastmod).format('MMM D, YYYY HH:mm') %></div>
|
||||||
@ -40,6 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer blue-grey darken-4">
|
<div class="modal-footer blue-grey darken-4">
|
||||||
|
<a href="#!" class="waves-effect waves-green btn green restore modal-close" data-id="<%=backups[index].filename%>" data-name='<%= backups[index].basename ? backups[index].basename : backups[index].etag %>'>Backup now</a>
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn red">Close</a>
|
<a href="#!" class="modal-close waves-effect waves-green btn red">Close</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -81,10 +81,14 @@
|
|||||||
<nav class=" light-blue accent-4">
|
<nav class=" light-blue accent-4">
|
||||||
<div class="nav-wrapper container">
|
<div class="nav-wrapper container">
|
||||||
<a href="#" class="brand-logo"><img src="./images/Nextcloud_Logo.svg" height="54"
|
<a href="#" class="brand-logo"><img src="./images/Nextcloud_Logo.svg" height="54"
|
||||||
style="margin: 5px"></a>
|
style="margin: 5px">
|
||||||
|
</a>
|
||||||
<ul class="right">
|
<ul class="right">
|
||||||
<li id="setting-trigger"><a class="dropdown-trigger" href="#" data-target="dropdown-settings"><i
|
<li id="setting-trigger">
|
||||||
class="material-icons">settings</i></a></li>
|
<a class="dropdown-trigger" href="#" data-target="dropdown-settings">
|
||||||
|
<i class="material-icons">settings</i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div style="height: 64px; display: table; margin-left: 130px;" class="hide-on-med-and-down">
|
<div style="height: 64px; display: table; margin-left: 130px;" class="hide-on-med-and-down">
|
||||||
<h4 style="display: table-cell; vertical-align: middle;">Nextcloud Backup</h4>
|
<h4 style="display: table-cell; vertical-align: middle;">Nextcloud Backup</h4>
|
||||||
@ -181,6 +185,7 @@
|
|||||||
|
|
||||||
<%- include('modals/backup-settings-modal') %>
|
<%- include('modals/backup-settings-modal') %>
|
||||||
|
|
||||||
|
<%- include('modals/restore-modal.ejs') %>
|
||||||
|
|
||||||
<div id="modal-loading" class="modal blue-grey darken-4 white-text">
|
<div id="modal-loading" class="modal blue-grey darken-4 white-text">
|
||||||
<div class="modal-content ">
|
<div class="modal-content ">
|
||||||
@ -245,6 +250,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script src="./js/materialize.min.js"></script>
|
<script src="./js/materialize.min.js"></script>
|
||||||
<script src="./js/jquery-3.4.1.min.js"></script>
|
<script src="./js/jquery-3.4.1.min.js"></script>
|
||||||
@ -255,6 +261,8 @@
|
|||||||
var last_manu_back = "";
|
var last_manu_back = "";
|
||||||
var last_auto_back = "";
|
var last_auto_back = "";
|
||||||
|
|
||||||
|
var to_restore = "";
|
||||||
|
|
||||||
var loadingModal = null;
|
var loadingModal = null;
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
updateLocalSnaps();
|
updateLocalSnaps();
|
||||||
@ -274,7 +282,7 @@
|
|||||||
var elems = document.querySelectorAll('.collapsible');
|
var elems = document.querySelectorAll('.collapsible');
|
||||||
M.Collapsible.init(elems, { accordion: true });
|
M.Collapsible.init(elems, { accordion: true });
|
||||||
var modals = document.querySelectorAll('.modal:not(#modal-loading)');
|
var modals = document.querySelectorAll('.modal:not(#modal-loading)');
|
||||||
M.Modal.init(modals, { dismissible: false });
|
M.Modal.init(modals, { dismissible: true });
|
||||||
|
|
||||||
let loadingModals = document.querySelectorAll('#modal-loading');
|
let loadingModals = document.querySelectorAll('#modal-loading');
|
||||||
M.Modal.init(loadingModals, { dismissible: false });
|
M.Modal.init(loadingModals, { dismissible: false });
|
||||||
@ -290,6 +298,13 @@
|
|||||||
let name = this.getAttribute('data-name');
|
let name = this.getAttribute('data-name');
|
||||||
manualBackup(id, name);
|
manualBackup(id, name);
|
||||||
})
|
})
|
||||||
|
$('.restore').click(function(){
|
||||||
|
to_restore = this.getAttribute('data-id');
|
||||||
|
console.log(to_restore)
|
||||||
|
let restore_modal = M.Modal.getInstance(document.querySelector('#modal-restore'));
|
||||||
|
restore_modal.open();
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLocalSnaps() {
|
function updateLocalSnaps() {
|
||||||
@ -438,12 +453,28 @@
|
|||||||
div.removeClass("hide")
|
div.removeClass("hide")
|
||||||
else
|
else
|
||||||
div.addClass("hide");
|
div.addClass("hide");
|
||||||
})
|
});
|
||||||
|
|
||||||
|
$('#confirm-restore').click(function(){
|
||||||
|
restore(to_restore);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restore(id){
|
||||||
|
loadingModal.open();
|
||||||
|
$.post('./api/restore', {path: id})
|
||||||
|
.done((data)=>{
|
||||||
|
console.log("Restore cmd send !");
|
||||||
|
M.toast({ html: '<i class="material-icons" style="margin-right:10px">check_box</i> Command send !', classes: "green" });
|
||||||
|
}).fail((error) => {
|
||||||
|
console.log(error);
|
||||||
|
M.toast({ html: '<i class="material-icons" style="margin-right:10px">warning</i> Can\'t send command !', classes: "red" });
|
||||||
|
})
|
||||||
|
.always(()=> loadingModal.close())
|
||||||
|
}
|
||||||
|
|
||||||
function sendNextcloudSettings() {
|
function sendNextcloudSettings() {
|
||||||
loadingModal.open();
|
loadingModal.open();
|
||||||
@ -480,7 +511,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function manualBackup(id, name) {
|
function manualBackup(id, name) {
|
||||||
$.post('./api/manual-backup?id=' + id + '&name=' + name);
|
$.post('./api/manual-backup?id=' + id + '&name=' + name)
|
||||||
|
.done((data)=>{
|
||||||
|
console.log("manual bk cmd send !");
|
||||||
|
M.toast({ html: '<i class="material-icons" style="margin-right:10px">check_box</i> Command send !', classes: "green" });
|
||||||
|
}).fail((error) => {
|
||||||
|
console.log(error);
|
||||||
|
M.toast({ html: '<i class="material-icons" style="margin-right:10px">warning</i> Can\'t send command !', classes: "red" });
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer blue-grey darken-4">
|
<div class="modal-footer blue-grey darken-4">
|
||||||
<a href="#!" class="waves-effect waves-green btn light-blue accent-4 manual-back-list modal-close" data-id="<%=snaps[index].slug%>" data-name='<%= snaps[index].name ? snaps[index].name : snaps[index].slug %>'</a>Backup now</a>
|
<a href="#!" class="waves-effect waves-green btn green manual-back-list modal-close" data-id="<%=snaps[index].slug%>" data-name='<%= snaps[index].name ? snaps[index].name : snaps[index].slug %>'</a>Backup now</a>
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn red">Close</a>
|
<a href="#!" class="modal-close waves-effect waves-green btn red">Close</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
<div id="modal-restore" class="modal blue-grey darken-4 white-text">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12 center">
|
||||||
|
<h4>Restore snapshot</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12 center divider">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="margin-top: 40px;">
|
||||||
|
<h5 class="center">Are you sure you want to restore this snapshot ?</h5>
|
||||||
|
<h6 class="center">This will remplace all your data !</h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer blue-grey darken-4">
|
||||||
|
<a href="#!" id="confirm-restore" class="waves-effect waves-green btn green modal-close">Confirm</a>
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-green btn red">Cancel</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user