webapp: implemented delete existing files option for restore settings.

This commit is contained in:
Shreyas Zare
2021-01-17 18:12:34 +05:30
parent 3e5989de73
commit 4e57aa5b31
2 changed files with 18 additions and 2 deletions

View File

@@ -2247,9 +2247,22 @@
</div>
</div>
</div>
<p>Restore options:</p>
<div class="form-group">
<div style="padding-left: 40px;">
<div class="checkbox">
<label>
<input id="chkDeleteExistingFiles" type="checkbox" checked> Delete Existing Files
</label>
</div>
</div>
</div>
</div>
<p>Warning! The restore process will delete the existing files on disk for above selected items and reload new settings including passwords. If you do not remember the password used while creating the backup, you should reset the admin password immediately after restoring the backup. Failing to do so will require you to follow the password reset process.</p>
<p>Warning! The restore process will overwrite existing config files on disk for above selected items and reload new settings including passwords. If you do not remember the password used while creating the backup, you should reset the admin password immediately after restoring the backup. Failing to do so will require you to follow the password reset process.</p>
</div>
<div class="modal-footer">
<button id="btnRestoreSettings" type="submit" class="btn btn-primary" data-loading-text="Restoring..." onclick="return restoreSettings();">Restore</button>

View File

@@ -2144,6 +2144,7 @@ function resetRestoreSettingsModal() {
$("#chkRestoreStats").prop("checked", true);
$("#chkRestoreLogs").prop("checked", false);
$("#chkRestoreBlockLists").prop("checked", true);
$("#chkDeleteExistingFiles").prop("checked", true);
return false;
}
@@ -2169,6 +2170,8 @@ function restoreSettings() {
var dnsSettings = $("#chkRestoreDnsSettings").prop('checked');
var logSettings = $("#chkRestoreLogSettings").prop('checked');
var deleteExistingFiles = $("#chkDeleteExistingFiles").prop('checked');
if (!blockLists && !logs && !scopes && !stats && !zones && !allowedZones && !blockedZones && !dnsSettings && !logSettings) {
showAlert("warning", "Missing!", "Please select at least one item to restore.", divRestoreSettingsAlert);
return false;
@@ -2180,7 +2183,7 @@ function restoreSettings() {
var btn = $("#btnRestoreSettings").button('loading');
HTTPRequest({
url: "/api/restoreSettings?token=" + token + "&blockLists=" + blockLists + "&logs=" + logs + "&scopes=" + scopes + "&stats=" + stats + "&zones=" + zones + "&allowedZones=" + allowedZones + "&blockedZones=" + blockedZones + "&dnsSettings=" + dnsSettings + "&logSettings=" + logSettings,
url: "/api/restoreSettings?token=" + token + "&blockLists=" + blockLists + "&logs=" + logs + "&scopes=" + scopes + "&stats=" + stats + "&zones=" + zones + "&allowedZones=" + allowedZones + "&blockedZones=" + blockedZones + "&dnsSettings=" + dnsSettings + "&logSettings=" + logSettings + "&deleteExistingFiles=" + deleteExistingFiles,
data: formData,
dataIsFormData: true,
success: function (responseJSON) {