mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 11:11:26 -03:00
feat(frontend): enable downloads on Other page and default_other_roots settings UI
This commit is contained in:
@@ -1153,6 +1153,9 @@ export class SettingsManager {
|
||||
// Load default unet root
|
||||
await this.loadUnetRoots();
|
||||
|
||||
// Load default other-model roots (per sub_type)
|
||||
await this.loadOtherRoots();
|
||||
|
||||
// Load extra folder paths
|
||||
this.loadExtraFolderPaths();
|
||||
|
||||
@@ -1658,6 +1661,51 @@ export class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
async loadOtherRoots() {
|
||||
const selects = document.querySelectorAll('select[data-other-root-subtype]');
|
||||
if (!selects.length) return;
|
||||
|
||||
try {
|
||||
// Fetch other-model roots grouped by sub_type
|
||||
const response = await fetch('/api/lm/other/roots_by_subtype');
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch other model roots');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const groupedRoots = data.roots_by_subtype || {};
|
||||
const defaultRoots = state.global.settings.default_other_roots || {};
|
||||
|
||||
selects.forEach((select) => {
|
||||
const subType = select.dataset.otherRootSubtype;
|
||||
const roots = groupedRoots[subType] || [];
|
||||
if (!roots.length) {
|
||||
this.showNoRootsPlaceholder(select);
|
||||
return;
|
||||
}
|
||||
|
||||
select.innerHTML = '';
|
||||
select.disabled = false;
|
||||
|
||||
// Add options for each root
|
||||
roots.forEach(root => {
|
||||
const option = document.createElement('option');
|
||||
option.value = root;
|
||||
option.textContent = root;
|
||||
select.appendChild(option);
|
||||
});
|
||||
|
||||
const defaultRoot = defaultRoots[subType] || '';
|
||||
select.value = roots.includes(defaultRoot) ? defaultRoot : roots[0];
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading other model roots:', error);
|
||||
selects.forEach((select) => this.showNoRootsPlaceholder(select));
|
||||
showToast('toast.settings.otherRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async loadEmbeddingRoots() {
|
||||
const defaultEmbeddingRootSelect = document.getElementById('defaultEmbeddingRoot');
|
||||
if (!defaultEmbeddingRootSelect) return;
|
||||
@@ -2339,6 +2387,27 @@ export class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save one sub_type entry of the default_other_roots dict setting
|
||||
* (read-modify-write: the backend stores the whole mapping).
|
||||
*/
|
||||
async saveOtherRootSetting(subType, value) {
|
||||
try {
|
||||
const defaultRoots = { ...(state.global.settings.default_other_roots || {}) };
|
||||
if (value) {
|
||||
defaultRoots[subType] = value;
|
||||
} else {
|
||||
delete defaultRoots[subType];
|
||||
}
|
||||
|
||||
await this.saveSetting('default_other_roots', defaultRoots);
|
||||
|
||||
showToast('toast.settings.settingsUpdated', { setting: `default ${subType} root` }, 'success');
|
||||
} catch (error) {
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the recipes page layout (grid | masonry) and rebuild the scroller.
|
||||
* Shared entry point for the settings modal segmented control and the
|
||||
|
||||
Reference in New Issue
Block a user