added disable all button (#3917)

This commit is contained in:
gabryon99 2020-10-06 22:47:53 +02:00
parent 7320c8266c
commit d0f1502e69
4 changed files with 29 additions and 2 deletions

View file

@ -1532,6 +1532,8 @@ $(document).ready(function () {
}
const [enabled_count, disabled_count] = count_scripts();
// enable the disable all button if there are more than one enabled scripts
if (enabled_count > 0) $(`#btn-disable-all`).removeAttr('disabled');
// select the correct tab
select_script_filter(enabled_count);
@ -1744,4 +1746,24 @@ $(document).ready(function () {
});
});
$(`#btn-disable-all`).click(async function() {
$(this).attr("disabled", "disabled");
$.post(`${http_prefix}/lua/toggle_all_user_scripts.lua`, {
action: 'disable',
script_subdir: script_subdir,
confset_id: confset_id,
csrf: pageCsrf
})
.then((result) => {
if (result.success) location.reload();
})
.catch((error) => {
console.error(error);
})
.always(() => {
$(`#btn-disable-all`).removeAttr("disabled");
})
})
});