🔨 Add Settings for autostop addons

This commit is contained in:
SebClem 2021-02-06 20:20:24 +01:00
parent 59fc4fd4a9
commit 11b83a86f3
3 changed files with 79 additions and 15 deletions

View File

@ -397,6 +397,14 @@ function getBackupSettings() {
addons_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input addons-box" type="checkbox" id="${thisAddon.slug}" ${exclude ? "" : "checked"}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>` addons_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input addons-box" type="checkbox" id="${thisAddon.slug}" ${exclude ? "" : "checked"}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>`
} }
$("#addons-div").html(addons_html); $("#addons-div").html(addons_html);
let addons_stop_html = ""
for (let thisAddon of data.addonList) {
let on = data.settings.auto_stop_addon.includes(thisAddon.slug);
addons_stop_html += `<li class="list-group-item"><div class="form-check"><input class="form-check-input stop-addons-box" type="checkbox" id="${thisAddon.slug}" ${on ? "checked" : ""}><label class="form-label mb-0" for="${thisAddon.slug}">${thisAddon.name}</label></div></li>`
}
$("#auto-stop-addons-div").html(addons_stop_html);
updateDropVisibility(); updateDropVisibility();
backup_setting_modal.show(); backup_setting_modal.show();
@ -464,6 +472,12 @@ function sendBackupSettings() {
exclude_addon.push(i.id); exclude_addon.push(i.id);
} }
let stop_addons_nodes = document.querySelectorAll('.stop-addons-box:checked');
let stop_addon = [""];
for (let i of stop_addons_nodes) {
stop_addon.push(i.id);
}
loadingModal.show(); loadingModal.show();
backup_setting_modal.hide(); backup_setting_modal.hide();
$.post('./api/backup-settings', $.post('./api/backup-settings',
@ -479,6 +493,7 @@ function sendBackupSettings() {
auto_clean_backup_keep: auto_clean_backup_keep, auto_clean_backup_keep: auto_clean_backup_keep,
exclude_addon: exclude_addon, exclude_addon: exclude_addon,
exclude_folder: exclude_folder, exclude_folder: exclude_folder,
auto_stop_addon: stop_addon,
password_protected: password_protected, password_protected: password_protected,
password_protect_value: password_protect_value password_protect_value: password_protect_value
}) })

View File

@ -105,6 +105,15 @@ function check(conf, fallback = false) {
return false; return false;
} }
} }
if (conf.auto_stop_addon == null) {
if (fallback) {
logger.warn("Bad value for 'auto_stop_addon', fallback to [] ")
conf.auto_stop_addon = []
} else {
logger.error("Bad value for 'auto_stop_addon'")
return false;
}
}
if (!Array.isArray(conf.exclude_folder)) { if (!Array.isArray(conf.exclude_folder)) {
logger.debug("exclude_folder is not array (Empty value), reset..."); logger.debug("exclude_folder is not array (Empty value), reset...");

View File

@ -20,20 +20,6 @@
</span> </span>
</div> </div>
</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="row mt-3">
<div class="col-12 col-lg-6"> <div class="col-12 col-lg-6">
<div class="row"> <div class="row">
@ -64,7 +50,36 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row my-3">
<div class="col-12 text-center border-secondary border"></div>
</div>
<div class="row">
<div class="col-12 text-center">
<h4>Security</h4>
</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 my-3">
<div class="col-12 text-center border-secondary border"></div>
</div>
<div class="row">
<div class="col-12 text-center">
<h4>Automation</h4>
</div>
</div>
<div class="row mt-2"> <div class="row mt-2">
<div class="col-12 col-lg-10 offset-lg-1"> <div class="col-12 col-lg-10 offset-lg-1">
<label for="cron-drop-settings" class="form-label">Auto Backup</label> <label for="cron-drop-settings" class="form-label">Auto Backup</label>
@ -105,7 +120,32 @@
<input type="number" class="form-control" id="cron-drop-day-month" min="1" max="28"> <input type="number" class="form-control" id="cron-drop-day-month" min="1" max="28">
</div> </div>
</div> </div>
<div class="row my-3">
<div class="col-12 text-center border-secondary border"></div>
</div>
<div class="row mt-3"> <div class="row mt-3">
<div class="col-12 text-center">
<h4>Auto Stop Addons</h4>
</div>
<div class="col-12 text-center">
<p><i>Auto stopped Addons before backup</i></p>
</div>
</div>
<div class="row mt-3">
<div class="col-12 col-lg-10 offset-lg-1">
<ul id="auto-stop-addons-div" class="list-group">
</ul>
</div>
</div>
<div class="row my-3">
<div class="col-12 text-center border-secondary border"></div>
</div>
<div class="row">
<div class="col-12 text-center"> <div class="col-12 text-center">
<h4>Auto Clean Settings</h4> <h4>Auto Clean Settings</h4>
</div> </div>