mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
refactor: Implement common endpoint handlers for model management in ModelRouteUtils and update routes in CheckpointsRoutes
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { modalManager } from '../managers/ModalManager.js';
|
||||
|
||||
let pendingDeletePath = null;
|
||||
let pendingModelType = null;
|
||||
|
||||
export function showDeleteModal(filePath) {
|
||||
event.stopPropagation();
|
||||
export function showDeleteModal(filePath, modelType = 'lora') {
|
||||
// event.stopPropagation();
|
||||
pendingDeletePath = filePath;
|
||||
pendingModelType = modelType;
|
||||
|
||||
const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||
const modelName = card.dataset.name;
|
||||
@@ -23,11 +25,15 @@ export function showDeleteModal(filePath) {
|
||||
export async function confirmDelete() {
|
||||
if (!pendingDeletePath) return;
|
||||
|
||||
const modal = document.getElementById('deleteModal');
|
||||
const card = document.querySelector(`.lora-card[data-filepath="${pendingDeletePath}"]`);
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/delete_model', {
|
||||
// Use the appropriate endpoint based on model type
|
||||
const endpoint = pendingModelType === 'checkpoint' ?
|
||||
'/api/checkpoints/delete' :
|
||||
'/api/delete_model';
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -53,4 +59,6 @@ export async function confirmDelete() {
|
||||
|
||||
export function closeDeleteModal() {
|
||||
modalManager.closeModal('deleteModal');
|
||||
}
|
||||
pendingDeletePath = null;
|
||||
pendingModelType = null;
|
||||
}
|
||||
Reference in New Issue
Block a user