2023-05-17 12:46:58 +00:00
|
|
|
|
2023-04-30 19:12:24 +00:00
|
|
|
function extensions_apply(_disabled_list, _update_list, disable_all) {
|
2023-01-28 12:57:56 +00:00
|
|
|
var disable = [];
|
|
|
|
var update = [];
|
2024-02-09 14:19:16 +00:00
|
|
|
const extensions_input = gradioApp().querySelectorAll('#extensions input[type="checkbox"]');
|
|
|
|
if (extensions_input.length == 0) {
|
|
|
|
throw Error("Extensions page not yet loaded.");
|
|
|
|
}
|
|
|
|
extensions_input.forEach(function(x) {
|
2022-10-31 14:36:45 +00:00
|
|
|
if (x.name.startsWith("enable_") && !x.checked) {
|
2023-04-30 19:15:59 +00:00
|
|
|
disable.push(x.name.substring(7));
|
2023-05-17 12:46:58 +00:00
|
|
|
}
|
|
|
|
|
2022-10-31 14:36:45 +00:00
|
|
|
if (x.name.startsWith("update_") && x.checked) {
|
2023-04-30 19:15:59 +00:00
|
|
|
update.push(x.name.substring(7));
|
2023-05-17 12:46:58 +00:00
|
|
|
}
|
2022-10-31 14:36:45 +00:00
|
|
|
});
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2022-10-31 14:36:45 +00:00
|
|
|
restart_reload();
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-03-27 16:44:49 +00:00
|
|
|
return [JSON.stringify(disable), JSON.stringify(update), disable_all];
|
2022-10-31 14:36:45 +00:00
|
|
|
}
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-04-30 19:12:24 +00:00
|
|
|
function extensions_check() {
|
2023-01-28 12:57:56 +00:00
|
|
|
var disable = [];
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-01-28 12:57:56 +00:00
|
|
|
gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x) {
|
|
|
|
if (x.name.startsWith("enable_") && !x.checked) {
|
2023-04-30 19:15:59 +00:00
|
|
|
disable.push(x.name.substring(7));
|
2023-05-17 12:46:58 +00:00
|
|
|
}
|
2023-01-28 12:57:56 +00:00
|
|
|
});
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2022-10-31 14:36:45 +00:00
|
|
|
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x) {
|
|
|
|
x.innerHTML = "Loading...";
|
|
|
|
});
|
2023-05-17 12:46:58 +00:00
|
|
|
|
|
|
|
|
2023-01-28 12:57:56 +00:00
|
|
|
var id = randomId();
|
2023-08-30 05:05:18 +00:00
|
|
|
requestProgress(id, gradioApp().getElementById('extensions_installed_html'), null, function() {
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-01-28 12:57:56 +00:00
|
|
|
});
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-01-28 12:57:56 +00:00
|
|
|
return [id, JSON.stringify(disable)];
|
2022-11-01 06:59:00 +00:00
|
|
|
}
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2022-11-01 06:59:00 +00:00
|
|
|
function install_extension_from_index(button, url) {
|
|
|
|
button.disabled = "disabled";
|
|
|
|
button.value = "Installing...";
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-04-30 19:08:52 +00:00
|
|
|
var textarea = gradioApp().querySelector('#extension_to_install textarea');
|
2022-11-01 06:59:00 +00:00
|
|
|
textarea.value = url;
|
2023-01-17 11:15:47 +00:00
|
|
|
updateInput(textarea);
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2022-11-01 06:59:00 +00:00
|
|
|
gradioApp().querySelector('#install_extension_button').click();
|
|
|
|
}
|
2023-05-17 12:46:58 +00:00
|
|
|
|
2023-03-29 21:46:03 +00:00
|
|
|
function config_state_confirm_restore(_, config_state_name, config_restore_type) {
|
|
|
|
if (config_state_name == "Current") {
|
2023-03-29 23:32:54 +00:00
|
|
|
return [false, config_state_name, config_restore_type];
|
2023-03-29 21:46:03 +00:00
|
|
|
}
|
|
|
|
let restored = "";
|
|
|
|
if (config_restore_type == "extensions") {
|
|
|
|
restored = "all saved extension versions";
|
|
|
|
} else if (config_restore_type == "webui") {
|
|
|
|
restored = "the webui version";
|
|
|
|
} else {
|
|
|
|
restored = "the webui version and all saved extension versions";
|
|
|
|
}
|
2023-03-29 23:32:54 +00:00
|
|
|
let confirmed = confirm("Are you sure you want to restore from this state?\nThis will reset " + restored + ".");
|
|
|
|
if (confirmed) {
|
|
|
|
restart_reload();
|
|
|
|
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x) {
|
|
|
|
x.innerHTML = "Loading...";
|
|
|
|
});
|
|
|
|
}
|
2023-03-29 21:46:03 +00:00
|
|
|
return [confirmed, config_state_name, config_restore_type];
|
|
|
|
}
|
2023-06-25 03:30:08 +00:00
|
|
|
|
|
|
|
function toggle_all_extensions(event) {
|
|
|
|
gradioApp().querySelectorAll('#extensions .extension_toggle').forEach(function(checkbox_el) {
|
|
|
|
checkbox_el.checked = event.target.checked;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggle_extension() {
|
|
|
|
let all_extensions_toggled = true;
|
|
|
|
for (const checkbox_el of gradioApp().querySelectorAll('#extensions .extension_toggle')) {
|
|
|
|
if (!checkbox_el.checked) {
|
|
|
|
all_extensions_toggled = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gradioApp().querySelector('#extensions .all_extensions_toggle').checked = all_extensions_toggled;
|
|
|
|
}
|