Files
ComfyUI-Lora-Manager/static/js/api/loraApi.js
Will Miao fc29cde82a feat(versions): add View all local versions button to model versions tab
Clicking the button closes the modal, writes filter params to sessionStorage,
and reloads the page to show all local versions of the model as individual
cards (bypassing group-by-model dedup). The filter respects the update flag
strategy and the versions-filter-toggle state (same-base vs all versions).

Supporting changes:
- sessionStorage keys vlm_model_id / vlm_model_name / vlm_base_model
- BaseModelApiClient._addModelSpecificParams adds civitai_model_id param
- LoraApiClient calls super._addModelSpecificParams for VLM detection
- LorasControls / CheckpointsControls clearCustomFilter checks VLM first
- PageControls.checkVlmFilter shows customFilterIndicator with label
- Backend parses civitai_model_id, filters before group_by_model dedup
2026-06-21 11:13:53 +08:00

101 lines
3.1 KiB
JavaScript

import { BaseModelApiClient } from './baseModelApi.js';
import { getSessionItem } from '../utils/storageHelpers.js';
/**
* LoRA-specific API client
*/
export class LoraApiClient extends BaseModelApiClient {
/**
* Add LoRA-specific parameters to query
*/
_addModelSpecificParams(params, pageState) {
// Let parent handle View Local Versions filter first
super._addModelSpecificParams(params, pageState);
// If VLM filter was applied, skip recipe-specific filters
if (params.has('civitai_model_id')) {
return;
}
const filterLoraHash = getSessionItem('recipe_to_lora_filterLoraHash');
const filterLoraHashes = getSessionItem('recipe_to_lora_filterLoraHashes');
if (filterLoraHash) {
params.append('lora_hash', filterLoraHash);
} else if (filterLoraHashes) {
try {
if (Array.isArray(filterLoraHashes) && filterLoraHashes.length > 0) {
params.append('lora_hashes', filterLoraHashes.join(','));
}
} catch (error) {
console.error('Error parsing lora hashes from session storage:', error);
}
}
}
/**
* Get LoRA notes
*/
async getLoraNote(filePath) {
try {
const response = await fetch(this.apiConfig.endpoints.specific.notes,
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ file_path: filePath })
}
);
if (!response.ok) {
throw new Error('Failed to fetch LoRA notes');
}
return await response.json();
} catch (error) {
console.error('Error fetching LoRA notes:', error);
throw error;
}
}
/**
* Get LoRA trigger words
*/
async getLoraTriggerWords(filePath) {
try {
const response = await fetch(this.apiConfig.endpoints.specific.triggerWords, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ file_path: filePath })
});
if (!response.ok) {
throw new Error('Failed to fetch trigger words');
}
return await response.json();
} catch (error) {
console.error('Error fetching trigger words:', error);
throw error;
}
}
/**
* Get letter counts for LoRAs
*/
async getLetterCounts() {
try {
const response = await fetch(this.apiConfig.endpoints.specific.letterCounts);
if (!response.ok) {
throw new Error('Failed to fetch letter counts');
}
return await response.json();
} catch (error) {
console.error('Error fetching letter counts:', error);
throw error;
}
}
}