Add bulk delete endpoint for checkpoints and enhance ModelDuplicatesManager for better handling of model types

This commit is contained in:
Will Miao
2025-06-02 08:54:31 +08:00
parent 26f9779fbf
commit 7545312229
5 changed files with 41 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ class CheckpointsPageManager {
window.checkpointDownloadManager = new CheckpointDownloadManager();
// Initialize the ModelDuplicatesManager
this.duplicatesManager = new ModelDuplicatesManager(this);
this.duplicatesManager = new ModelDuplicatesManager(this, 'checkpoints');
// Expose only necessary functions to global scope
this._exposeRequiredGlobalFunctions();

View File

@@ -1,16 +1,15 @@
// Model Duplicates Manager Component for LoRAs and Checkpoints
import { showToast } from '../utils/uiHelpers.js';
import { state, getCurrentPageState } from '../state/index.js';
import { initializeInfiniteScroll } from '../utils/infiniteScroll.js';
import { formatDate } from '../utils/formatters.js';
export class ModelDuplicatesManager {
constructor(pageManager) {
constructor(pageManager, modelType = 'loras') {
this.pageManager = pageManager;
this.duplicateGroups = [];
this.inDuplicateMode = false;
this.selectedForDeletion = new Set();
this.modelType = 'loras'; // Default to loras, could be 'checkpoints'
this.modelType = modelType; // Use the provided modelType or default to 'loras'
// Bind methods
this.renderModelCard = this.renderModelCard.bind(this);
@@ -91,11 +90,11 @@ export class ModelDuplicatesManager {
// Instead of trying to restore the virtual scroller,
// simply redirect to reload the page
// TODO: While this is a workaround rather than a deep fix, it's a pragmatic solution that will immediately resolve the issue for users. We can investigate the underlying cause more thoroughly later when there's time for more extensive debugging.
window.location.href = '/loras';
window.location.href = `/${this.modelType}`;
}
renderDuplicateGroups() {
const modelGrid = document.getElementById('loraGrid');
const modelGrid = document.getElementById(this.modelType === 'loras' ? 'loraGrid' : 'checkpointGrid');
if (!modelGrid) return;
// Clear existing content