Enhance model metadata saving functionality with loading indicators and improved validation. Refactor editing logic for better user experience in both checkpoint and LoRA modals. Fixes #200

This commit is contained in:
Will Miao
2025-05-30 16:30:01 +08:00
parent c62206a157
commit cbb25b4ac0
6 changed files with 192 additions and 108 deletions

View File

@@ -120,22 +120,30 @@ export async function refreshSingleCheckpointMetadata(filePath) {
* @returns {Promise} - Promise that resolves with the server response
*/
export async function saveModelMetadata(filePath, data) {
const response = await fetch('/api/checkpoints/save-metadata', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
file_path: filePath,
...data
})
});
try {
// Show loading indicator
state.loadingManager.showSimpleLoading('Saving metadata...');
const response = await fetch('/api/checkpoints/save-metadata', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
file_path: filePath,
...data
})
});
if (!response.ok) {
throw new Error('Failed to save metadata');
if (!response.ok) {
throw new Error('Failed to save metadata');
}
return response.json();
} finally {
// Always hide the loading indicator when done
state.loadingManager.hide();
}
return response.json();
}
/**

View File

@@ -21,22 +21,30 @@ import { state, getCurrentPageState } from '../state/index.js';
* @returns {Promise} Promise of the save operation
*/
export async function saveModelMetadata(filePath, data) {
const response = await fetch('/api/loras/save-metadata', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
file_path: filePath,
...data
})
});
try {
// Show loading indicator
state.loadingManager.showSimpleLoading('Saving metadata...');
const response = await fetch('/api/loras/save-metadata', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
file_path: filePath,
...data
})
});
if (!response.ok) {
throw new Error('Failed to save metadata');
if (!response.ok) {
throw new Error('Failed to save metadata');
}
return response.json();
} finally {
// Always hide the loading indicator when done
state.loadingManager.hide();
}
return response.json();
}
/**