mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-22 01:02:59 +01:00
🔨 Add password protected option for snapshots #42
This commit is contained in:
parent
ee25207856
commit
7a5aa7b0b8
@ -181,6 +181,13 @@ function listeners() {
|
||||
$('#btn-clean-now').click(cleanNow);
|
||||
|
||||
$('#trigger-backup-settings').click(getBackupSettings);
|
||||
$('#password_protected').change(function () {
|
||||
if (!$(this).is(':checked')) {
|
||||
$('#password_protect_value').parent().parent().addClass('d-none');
|
||||
} else {
|
||||
$('#password_protect_value').parent().parent().removeClass('d-none');
|
||||
}
|
||||
})
|
||||
$('#cron-drop-settings').change(updateDropVisibility);
|
||||
$('#save-backup-settings').click(sendBackupSettings);
|
||||
$('#auto_clean_local').change(function () {
|
||||
@ -445,6 +452,8 @@ function sendBackupSettings() {
|
||||
let name_template = $('#name-template').val();
|
||||
let excluded_folders_nodes = document.querySelectorAll('.folders-box:not(:checked)');
|
||||
let exclude_folder = [""];
|
||||
let password_protected = $('#password_protected').is(':checked');
|
||||
let password_protect_value = $('#password_protect_value').val();
|
||||
for (let i of excluded_folders_nodes) {
|
||||
exclude_folder.push(i.id);
|
||||
}
|
||||
@ -469,7 +478,9 @@ function sendBackupSettings() {
|
||||
auto_clean_backup: auto_clean_backup,
|
||||
auto_clean_backup_keep: auto_clean_backup_keep,
|
||||
exclude_addon: exclude_addon,
|
||||
exclude_folder: exclude_folder
|
||||
exclude_folder: exclude_folder,
|
||||
password_protected: password_protected,
|
||||
password_protect_value: password_protect_value
|
||||
})
|
||||
.done(() => {
|
||||
create_toast("success", "Backup settings saved !", default_toast_timeout);
|
||||
|
@ -284,6 +284,9 @@ function createNewBackup(name) {
|
||||
folders: folders
|
||||
},
|
||||
};
|
||||
if(settingsTools.getSettings().password_protected === "true"){
|
||||
option.json.password = settingsTools.getSettings().password_protect_value
|
||||
}
|
||||
|
||||
got.post(`http://hassio/snapshots/new/partial`, option)
|
||||
.then((result) => {
|
||||
|
@ -116,6 +116,25 @@ function check(conf, fallback = false) {
|
||||
conf.exclude_addon = []
|
||||
needSave = true;
|
||||
}
|
||||
if(conf.password_protected == null){
|
||||
if (fallback) {
|
||||
logger.warn("Bad value for 'password_protected', fallback to false ");
|
||||
conf.password_protected = 'false';
|
||||
} else {
|
||||
logger.error("Bad value for 'password_protect_value'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(conf.password_protect_value == null){
|
||||
if (fallback) {
|
||||
logger.warn("Bad value for 'password_protect_value', fallback to '' ");
|
||||
conf.password_protect_value = '';
|
||||
} else {
|
||||
logger.error("Bad value for 'password_protect_value'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (fallback || needSave) {
|
||||
setSettings(conf);
|
||||
|
@ -20,6 +20,50 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col-lg-10 offset-lg-1 col-12">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" id="password_protected" type="checkbox">
|
||||
<label class="form-check-label" for="password_protected">Password Protected</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-2 d-none">
|
||||
<div class="col-lg-10 offset-lg-1 col-12">
|
||||
<label for="password_protect_value" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password_protect_value" min="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
<h5>Folders</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ul id="folders-div" class="list-group">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
<h5>Addons</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ul id="addons-div" class="list-group">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col-12 col-lg-10 offset-lg-1">
|
||||
@ -61,36 +105,6 @@
|
||||
<input type="number" class="form-control" id="cron-drop-day-month" min="1" max="28">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
<h5>Folders</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ul id="folders-div" class="list-group">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
<h5>Addons</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ul id="addons-div" class="list-group">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col-12 text-center">
|
||||
<h4>Auto Clean Settings</h4>
|
||||
@ -102,7 +116,8 @@
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" id="auto_clean_local" type="checkbox">
|
||||
<label class="form-check-label" for="auto_clean_local">Auto Clean Local Snapshots</label>
|
||||
<label class="form-check-label" for="auto_clean_local">Auto Clean Local
|
||||
Snapshots</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -119,10 +134,10 @@
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" id="auto_clean_backup" type="checkbox">
|
||||
<label class="form-check-label" for="auto_clean_backup">Auto Clean Nextcloud Snapshots</label>
|
||||
<label class="form-check-label" for="auto_clean_backup">Auto Clean Nextcloud
|
||||
Snapshots</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col-12">
|
||||
|
Loading…
Reference in New Issue
Block a user