mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
feat: refactor API routes for renaming models and update related functions
This commit is contained in:
@@ -2,47 +2,6 @@
|
||||
* Utility functions to update checkpoint cards after modal edits
|
||||
*/
|
||||
|
||||
/**
|
||||
* Update the Lora card after metadata edits in the modal
|
||||
* @param {string} filePath - Path to the Lora file
|
||||
* @param {Object} updates - Object containing the updates (model_name, base_model, notes, usage_tips, etc)
|
||||
*/
|
||||
export function updateModelCard(filePath, updates) {
|
||||
// Find the card with matching filepath
|
||||
const modelCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||
if (!modelCard) return;
|
||||
|
||||
// Update card dataset and visual elements based on the updates object
|
||||
Object.entries(updates).forEach(([key, value]) => {
|
||||
// Update dataset
|
||||
modelCard.dataset[key] = value;
|
||||
|
||||
// Update visual elements based on the property
|
||||
switch(key) {
|
||||
case 'model_name':
|
||||
// Update the model name in the card title
|
||||
const titleElement = modelCard.querySelector('.card-title');
|
||||
if (titleElement) titleElement.textContent = value;
|
||||
|
||||
// Also update the model name in the footer if it exists
|
||||
const modelNameElement = modelCard.querySelector('.model-name');
|
||||
if (modelNameElement) modelNameElement.textContent = value;
|
||||
break;
|
||||
|
||||
case 'base_model':
|
||||
// Update the base model label in the card header if it exists
|
||||
const baseModelLabel = modelCard.querySelector('.base-model-label');
|
||||
if (baseModelLabel) {
|
||||
baseModelLabel.textContent = value;
|
||||
baseModelLabel.title = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return modelCard; // Return the updated card element for chaining
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the recipe card after metadata edits in the modal
|
||||
* @param {string} recipeId - ID of the recipe to update
|
||||
|
||||
Reference in New Issue
Block a user