Added save/delete functionality in the UI for config presets

New buttons: Add/Remove..., 🗑️, Create, Open..., Cancel
New textbox: New preset name
This commit is contained in:
Zyin055
2022-12-20 21:16:12 -06:00
parent 4503743faf
commit 6d6c466071
2 changed files with 318 additions and 127 deletions

View File

@@ -4,7 +4,12 @@
//or do it our more precise way
onUiUpdate(function() {
//set tooltips
gradioApp().querySelectorAll("#config_presets_open_config_file_button").forEach(el => el.setAttribute("title", "[Config Presets] open config.json, requires Gradio restart after editing"))
gradioApp().querySelectorAll("#config_presets_open_config_file_button").forEach(el => el.setAttribute("title", "Open the config.json file for manual editing if you want to make changes that way, requires Gradio restart after editing"))
gradioApp().querySelectorAll("#config_preset_save_textbox").forEach(el => el.setAttribute("title", "The label that will be displayed in the dropdown to the left"))
gradioApp().querySelectorAll("#config_preset_save_button").forEach(el => el.setAttribute("title", "Saves current settings with the new preset name"))
gradioApp().querySelectorAll("#config_preset_add_button").forEach(el => el.setAttribute("title", "[Config Presets] Add or remove a preset"))
gradioApp().querySelectorAll("#config_preset_cancel_save_button").forEach(el => el.setAttribute("title", "Go back"))
gradioApp().querySelectorAll("#config_preset_trash_button").forEach(el => el.setAttribute("title", "Permanently delete selected preset"))
})
//change() event called by config_preset_dropdown in config_presets.py
@@ -20,4 +25,11 @@ function config_preset_dropdown_change() {
e.initEvent("change", true, false)
highresCheckbox.dispatchEvent(e)
}, 200) //50ms is too fast
}
function config_presets_add_new_preset() {
console.log("config_presets_add_new_preset()")
const temp = prompt("name?")
console.log("returning temp="+temp)
return temp
}