Prevent on server side deletion of folders other than in models in the executing directory
Removed delete icon for model folders outside the models directory
This commit is contained in:
parent
f444ad851f
commit
095cd2a19d
|
@ -369,9 +369,13 @@ def sendModelSelection(menu="mainmenu", folder="./models"):
|
|||
breadcrumbs = []
|
||||
menu_list = [[folder, menu, "", False] for folder in paths]
|
||||
menu_list.append(["Return to Main Menu", "mainmenu", "", True])
|
||||
emit('from_server', {'cmd': 'show_model_menu', 'data': menu_list, 'menu': menu, 'breadcrumbs': breadcrumbs}, broadcast=True)
|
||||
if os.path.abspath("{}/models".format(os.getcwd())) == os.path.abspath(folder):
|
||||
showdelete=True
|
||||
else:
|
||||
showdelete=False
|
||||
emit('from_server', {'cmd': 'show_model_menu', 'data': menu_list, 'menu': menu, 'breadcrumbs': breadcrumbs, "showdelete": showdelete}, broadcast=True)
|
||||
else:
|
||||
emit('from_server', {'cmd': 'show_model_menu', 'data': model_menu[menu], 'menu': menu, 'breadcrumbs': []}, broadcast=True)
|
||||
emit('from_server', {'cmd': 'show_model_menu', 'data': model_menu[menu], 'menu': menu, 'breadcrumbs': [], "showdelete": False}, broadcast=True)
|
||||
|
||||
def get_folder_path_info(base):
|
||||
if base == 'This PC':
|
||||
|
|
|
@ -998,7 +998,7 @@ function hideUSPopup() {
|
|||
}
|
||||
|
||||
|
||||
function buildLoadModelList(ar, menu, breadcrumbs) {
|
||||
function buildLoadModelList(ar, menu, breadcrumbs, showdelete) {
|
||||
disableButtons([load_model_accept]);
|
||||
loadmodelcontent.html("");
|
||||
$("#loadmodellistbreadcrumbs").html("");
|
||||
|
@ -1037,7 +1037,7 @@ function buildLoadModelList(ar, menu, breadcrumbs) {
|
|||
}
|
||||
|
||||
//now let's do the delete icon if applicable
|
||||
if (['NeoCustom', 'GPT2Custom'].includes(menu) && !ar[i][3]) {
|
||||
if (['NeoCustom', 'GPT2Custom'].includes(menu) && !ar[i][3] && showdelete) {
|
||||
html = html + "<span class=\"loadlisticon loadmodellisticon-folder oi oi-x allowed\" aria-hidden=\"true\" onclick='if(confirm(\"This will delete the selected folder with all contents. Are you sure?\")) { socket.send({\"cmd\": \"delete_model\", \"data\": \""+full_path.replaceAll("\\", "\\\\")+"\", \"menu\": \""+menu+"\"});}'></span>"
|
||||
} else {
|
||||
html = html + "<div class=\"loadlistpadding\"></div>"
|
||||
|
@ -2526,7 +2526,7 @@ $(document).ready(function(){
|
|||
$("#modelkey").addClass("hidden");
|
||||
$("#modellayers").addClass("hidden");
|
||||
$("#oaimodel").addClass("hidden")
|
||||
buildLoadModelList(msg.data, msg.menu, msg.breadcrumbs);
|
||||
buildLoadModelList(msg.data, msg.menu, msg.breadcrumbs, msg.showdelete);
|
||||
} else if(msg.cmd == 'selected_model_info') {
|
||||
enableButtons([load_model_accept]);
|
||||
$("#oaimodel").addClass("hidden")
|
||||
|
|
Loading…
Reference in New Issue