mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-06-22 11:21:15 -03:00
Compare commits
3 Commits
df67bd396a
...
54bcdfab38
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54bcdfab38 | ||
|
|
2e7532eecc | ||
|
|
7e5e3b1ec7 |
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "Keine Ordner gefunden",
|
||||
"dragHint": "Elemente hierher ziehen, um Ordner zu erstellen"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "Auf Updates in diesem Ordner prüfen",
|
||||
"loading": "Prüfe {type}-Updates in diesem Ordner...",
|
||||
"success": "{count} Update(s) für {type}s in diesem Ordner gefunden",
|
||||
"none": "Alle {type}s in diesem Ordner sind aktuell",
|
||||
"error": "Fehler beim Prüfen des Ordners auf {type}-Updates: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "Zuvor heruntergeladen, aber derzeit nicht in Ihrer Bibliothek.",
|
||||
"alreadyInLibrary": "Bereits in Bibliothek",
|
||||
"autoOrganizedPath": "[Automatisch organisiert durch Pfadvorlage]",
|
||||
"fileSelection": {
|
||||
"title": "Dateiformat auswählen",
|
||||
"files": "Dateien",
|
||||
"select": "Datei auswählen"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "Ungültiges Civitai URL-Format",
|
||||
"noVersions": "Keine Versionen für dieses Modell verfügbar"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "No folders found",
|
||||
"dragHint": "Drag items here to create folders"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "Check for updates in this folder",
|
||||
"loading": "Checking {type} updates for this folder...",
|
||||
"success": "Found {count} update(s) for {type}s in this folder",
|
||||
"none": "All {type}s in this folder are up to date",
|
||||
"error": "Failed to check folder for {type} updates: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "Previously downloaded, but it is not currently in your library.",
|
||||
"alreadyInLibrary": "Already in Library",
|
||||
"autoOrganizedPath": "[Auto-organized by path template]",
|
||||
"fileSelection": {
|
||||
"title": "Select File Format",
|
||||
"files": "files",
|
||||
"select": "Select File"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "Invalid Civitai URL format",
|
||||
"noVersions": "No versions available for this model"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "No se encontraron carpetas",
|
||||
"dragHint": "Arrastra elementos aquí para crear carpetas"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "Buscar actualizaciones en esta carpeta",
|
||||
"loading": "Buscando actualizaciones de {type} en esta carpeta...",
|
||||
"success": "Se encontraron {count} actualización(es) para {type}s en esta carpeta",
|
||||
"none": "Todos los {type}s en esta carpeta están actualizados",
|
||||
"error": "Error al buscar actualizaciones de {type} en la carpeta: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "Descargado anteriormente, pero actualmente no está en tu biblioteca.",
|
||||
"alreadyInLibrary": "Ya en la biblioteca",
|
||||
"autoOrganizedPath": "[Auto-organizado por plantilla de ruta]",
|
||||
"fileSelection": {
|
||||
"title": "Seleccionar formato de archivo",
|
||||
"files": "archivos",
|
||||
"select": "Seleccionar archivo"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "Formato de URL de Civitai inválido",
|
||||
"noVersions": "No hay versiones disponibles para este modelo"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "Aucun dossier trouvé",
|
||||
"dragHint": "Faites glisser des éléments ici pour créer des dossiers"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "Vérifier les mises à jour dans ce dossier",
|
||||
"loading": "Vérification des mises à jour {type} dans ce dossier...",
|
||||
"success": "{count} mise(s) à jour trouvée(s) pour les {type}s dans ce dossier",
|
||||
"none": "Tous les {type}s dans ce dossier sont à jour",
|
||||
"error": "Échec de la vérification des mises à jour {type} dans ce dossier : {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "Déjà téléchargé, mais il n'est actuellement pas dans votre bibliothèque.",
|
||||
"alreadyInLibrary": "Déjà dans la bibliothèque",
|
||||
"autoOrganizedPath": "[Auto-organisé par modèle de chemin]",
|
||||
"fileSelection": {
|
||||
"title": "Choisir le format de fichier",
|
||||
"files": "fichiers",
|
||||
"select": "Choisir le fichier"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "Format d'URL Civitai invalide",
|
||||
"noVersions": "Aucune version disponible pour ce modèle"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "לא נמצאו תיקיות",
|
||||
"dragHint": "גרור פריטים לכאן כדי ליצור תיקיות"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "בדוק עדכונים בתיקייה זו",
|
||||
"loading": "בודק עדכוני {type} בתיקייה זו...",
|
||||
"success": "נמצאו {count} עדכון/ים עבור {type}s בתיקייה זו",
|
||||
"none": "כל ה-{type}s בתיקייה זו מעודכנים",
|
||||
"error": "נכשל בבדיקת עדכוני {type} בתיקייה: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "הורד בעבר, אך הוא אינו נמצא כרגע בספרייה שלך.",
|
||||
"alreadyInLibrary": "כבר בספרייה",
|
||||
"autoOrganizedPath": "[מאורגן אוטומטית לפי תבנית נתיב]",
|
||||
"fileSelection": {
|
||||
"title": "בחר פורמט קובץ",
|
||||
"files": "קבצים",
|
||||
"select": "בחר קובץ"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "פורמט URL של Civitai לא חוקי",
|
||||
"noVersions": "אין גרסאות זמינות למודל זה"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "フォルダが見つかりません",
|
||||
"dragHint": "ここへアイテムをドラッグしてフォルダを作成します"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "このフォルダのアップデートを確認",
|
||||
"loading": "このフォルダの{type}アップデートを確認中...",
|
||||
"success": "このフォルダの{type}sに{count}件のアップデートが見つかりました",
|
||||
"none": "このフォルダのすべての{type}sは最新です",
|
||||
"error": "フォルダの{type}アップデート確認に失敗しました: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "以前にダウンロード済みですが、現在はライブラリにありません。",
|
||||
"alreadyInLibrary": "既にライブラリ内",
|
||||
"autoOrganizedPath": "[パステンプレートによる自動整理]",
|
||||
"fileSelection": {
|
||||
"title": "ファイル形式を選択",
|
||||
"files": "ファイル",
|
||||
"select": "ファイルを選択"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "無効なCivitai URL形式",
|
||||
"noVersions": "このモデルの利用可能なバージョンがありません"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "폴더를 찾을 수 없습니다",
|
||||
"dragHint": "항목을 여기로 드래그하여 폴더를 만듭니다"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "이 폴더의 업데이트 확인",
|
||||
"loading": "이 폴더의 {type} 업데이트를 확인하는 중...",
|
||||
"success": "이 폴더에서 {type}s에 대한 {count}개 업데이트를 찾았습니다",
|
||||
"none": "이 폴더의 모든 {type}s가 최신 상태입니다",
|
||||
"error": "폴더의 {type} 업데이트 확인 실패: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "이전에 다운로드했지만 현재 라이브러리에 없습니다.",
|
||||
"alreadyInLibrary": "이미 라이브러리에 있음",
|
||||
"autoOrganizedPath": "[경로 템플릿으로 자동 정리됨]",
|
||||
"fileSelection": {
|
||||
"title": "파일 형식 선택",
|
||||
"files": "개 파일",
|
||||
"select": "파일 선택"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "잘못된 Civitai URL 형식",
|
||||
"noVersions": "이 모델에 사용 가능한 버전이 없습니다"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "Папки не найдены",
|
||||
"dragHint": "Перетащите элементы сюда, чтобы создать папки"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "Проверить обновления в этой папке",
|
||||
"loading": "Проверка обновлений {type} в этой папке...",
|
||||
"success": "Найдено {count} обновление(й) для {type}s в этой папке",
|
||||
"none": "Все {type}s в этой папке актуальны",
|
||||
"error": "Не удалось проверить папку на наличие обновлений {type}: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "Ранее загружено, но сейчас этого нет в вашей библиотеке.",
|
||||
"alreadyInLibrary": "Уже в библиотеке",
|
||||
"autoOrganizedPath": "[Автоматически организовано по шаблону пути]",
|
||||
"fileSelection": {
|
||||
"title": "Выбрать формат файла",
|
||||
"files": "файлов",
|
||||
"select": "Выбрать файл"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "Неверный формат URL Civitai",
|
||||
"noVersions": "Нет доступных версий для этой модели"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "未找到文件夹",
|
||||
"dragHint": "拖拽项目到此处以创建文件夹"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "检查此文件夹的更新",
|
||||
"loading": "正在检查此文件夹中的{type}更新...",
|
||||
"success": "在此文件夹中找到 {count} 个{type}更新",
|
||||
"none": "此文件夹中的所有{type}都是最新版本",
|
||||
"error": "检查文件夹{type}更新失败: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "之前已下载,但当前不在你的库中。",
|
||||
"alreadyInLibrary": "已存在于库中",
|
||||
"autoOrganizedPath": "【已按路径模板自动整理】",
|
||||
"fileSelection": {
|
||||
"title": "选择文件格式",
|
||||
"files": "个文件",
|
||||
"select": "选择文件"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "无效的 Civitai URL 格式",
|
||||
"noVersions": "此模型没有可用版本"
|
||||
|
||||
@@ -963,6 +963,13 @@
|
||||
"empty": {
|
||||
"noFolders": "未找到資料夾",
|
||||
"dragHint": "將項目拖到此處以建立資料夾"
|
||||
},
|
||||
"folderUpdateCheck": {
|
||||
"label": "檢查此資料夾的更新",
|
||||
"loading": "正在檢查此資料夾中的{type}更新...",
|
||||
"success": "在此資料夾中找到 {count} 個{type}更新",
|
||||
"none": "此資料夾中的所有{type}都是最新版本",
|
||||
"error": "檢查資料夾{type}更新失敗: {message}"
|
||||
}
|
||||
},
|
||||
"statistics": {
|
||||
@@ -1031,6 +1038,11 @@
|
||||
"downloadedTooltip": "先前已下載,但目前不在你的庫中。",
|
||||
"alreadyInLibrary": "已在庫存",
|
||||
"autoOrganizedPath": "[依路徑範本自動整理]",
|
||||
"fileSelection": {
|
||||
"title": "選擇檔案格式",
|
||||
"files": "個檔案",
|
||||
"select": "選擇檔案"
|
||||
},
|
||||
"errors": {
|
||||
"invalidUrl": "Civitai 網址格式無效",
|
||||
"noVersions": "此模型無可用版本"
|
||||
|
||||
@@ -1960,6 +1960,10 @@ class ModelUpdateHandler:
|
||||
if target_model_ids:
|
||||
target_model_ids = sorted(set(target_model_ids))
|
||||
|
||||
folder_path: Optional[str] = payload.get("folder_path")
|
||||
if folder_path is not None and not isinstance(folder_path, str):
|
||||
folder_path = None
|
||||
|
||||
provider = await self._get_civitai_provider()
|
||||
if provider is None:
|
||||
return web.json_response(
|
||||
@@ -1974,6 +1978,7 @@ class ModelUpdateHandler:
|
||||
provider,
|
||||
force_refresh=force_refresh,
|
||||
target_model_ids=target_model_ids or None,
|
||||
folder_path=folder_path,
|
||||
)
|
||||
if self._service.scanner.is_cancelled():
|
||||
return web.json_response(
|
||||
|
||||
@@ -689,6 +689,7 @@ class ModelUpdateService:
|
||||
*,
|
||||
force_refresh: bool = False,
|
||||
target_model_ids: Optional[Sequence[int]] = None,
|
||||
folder_path: Optional[str] = None,
|
||||
) -> Dict[int, ModelUpdateRecord]:
|
||||
"""Refresh update information for every model present in the cache."""
|
||||
scanner.reset_cancellation()
|
||||
@@ -703,6 +704,7 @@ class ModelUpdateService:
|
||||
local_versions = await self._collect_local_versions(
|
||||
scanner,
|
||||
target_model_ids=target_filter,
|
||||
folder_path=folder_path,
|
||||
)
|
||||
total_models = len(local_versions)
|
||||
if total_models == 0:
|
||||
@@ -1276,6 +1278,7 @@ class ModelUpdateService:
|
||||
scanner,
|
||||
*,
|
||||
target_model_ids: Optional[Sequence[int]] = None,
|
||||
folder_path: Optional[str] = None,
|
||||
) -> Dict[int, List[int]]:
|
||||
cache = await scanner.get_cached_data()
|
||||
mapping: Dict[int, set[int]] = {}
|
||||
@@ -1288,7 +1291,19 @@ class ModelUpdateService:
|
||||
if not target_set:
|
||||
return {}
|
||||
|
||||
normalized_folder = None
|
||||
if folder_path is not None:
|
||||
normalized_folder = folder_path.replace("\\", "/").strip("/")
|
||||
|
||||
for item in cache.raw_data:
|
||||
# Apply folder filter first (cheapest check)
|
||||
if normalized_folder is not None:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
item_folder = (item.get("folder") or "").replace("\\", "/").strip("/")
|
||||
if item_folder != normalized_folder and not item_folder.startswith(normalized_folder + "/"):
|
||||
continue
|
||||
|
||||
civitai = item.get("civitai") if isinstance(item, dict) else None
|
||||
if not isinstance(civitai, dict):
|
||||
continue
|
||||
|
||||
@@ -502,4 +502,170 @@
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* File Count Badge on Version Items */
|
||||
.file-select-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
background: oklch(var(--lora-accent) / 0.18);
|
||||
color: var(--lora-accent);
|
||||
font-size: inherit;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
border: 1px solid oklch(var(--lora-accent) / 0.35);
|
||||
user-select: none;
|
||||
box-shadow: 0 1px 2px oklch(var(--lora-accent) / 0.1);
|
||||
}
|
||||
|
||||
.file-select-badge:hover {
|
||||
background: oklch(var(--lora-accent) / 0.3);
|
||||
border-color: var(--lora-accent);
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 2px 6px oklch(var(--lora-accent) / 0.2);
|
||||
}
|
||||
|
||||
.file-select-badge:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.file-select-badge i {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.file-select-badge .badge-arrow {
|
||||
margin-left: 2px;
|
||||
font-size: 0.65em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* File Selection Step */
|
||||
.file-selection-header {
|
||||
margin-bottom: var(--space-3);
|
||||
}
|
||||
|
||||
.file-selection-header h3 {
|
||||
margin: 0 0 4px 0;
|
||||
font-size: 1.1em;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.file-selection-version-name {
|
||||
font-size: 0.9em;
|
||||
color: var(--text-color);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.file-selection-list {
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
margin: var(--space-2) 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.file-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--border-radius-sm);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
background: var(--bg-color);
|
||||
}
|
||||
|
||||
.file-option:hover {
|
||||
border-color: var(--lora-accent);
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.file-option.selected {
|
||||
border: 2px solid var(--lora-accent);
|
||||
background: oklch(var(--lora-accent) / 0.05);
|
||||
}
|
||||
|
||||
.file-option-radio {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.file-option-radio input[type="radio"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
accent-color: var(--lora-accent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.file-option-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.file-option-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.file-tag {
|
||||
display: inline-block;
|
||||
padding: 2px 7px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.8em;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.file-tag.format {
|
||||
background: oklch(var(--lora-accent) / 0.1);
|
||||
color: var(--lora-accent);
|
||||
}
|
||||
|
||||
.file-tag.fp {
|
||||
background: oklch(0.6 0.15 250 / 0.1);
|
||||
color: oklch(0.55 0.15 250);
|
||||
}
|
||||
|
||||
.file-tag.size {
|
||||
background: oklch(0.55 0.1 160 / 0.1);
|
||||
color: oklch(0.5 0.12 160);
|
||||
}
|
||||
|
||||
.file-option-name {
|
||||
font-size: 0.8em;
|
||||
color: var(--text-color);
|
||||
opacity: 0.6;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.file-option-size {
|
||||
font-size: 0.9em;
|
||||
color: var(--text-color);
|
||||
white-space: nowrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* Dark theme adjustments */
|
||||
[data-theme="dark"] .file-option {
|
||||
background: var(--lora-surface);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .file-tag.fp {
|
||||
background: oklch(0.55 0.12 250 / 0.15);
|
||||
color: oklch(0.7 0.12 250);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .file-tag.size {
|
||||
background: oklch(0.5 0.08 160 / 0.15);
|
||||
color: oklch(0.65 0.08 160);
|
||||
}
|
||||
@@ -745,3 +745,8 @@
|
||||
.sidebar-tree-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Folder context menu - positioned relative to sidebar */
|
||||
#sidebarFolderContextMenu {
|
||||
z-index: var(--z-modal, 1002);
|
||||
}
|
||||
|
||||
@@ -766,6 +766,49 @@ export class BaseModelApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
async refreshUpdatesForFolder(folderPath, { force = false } = {}) {
|
||||
if (!folderPath) {
|
||||
throw new Error('No folder path provided');
|
||||
}
|
||||
|
||||
try {
|
||||
state.loadingManager.show('Checking for updates...', 0);
|
||||
state.loadingManager.showCancelButton(() => this.cancelTask());
|
||||
|
||||
const response = await fetch(this.apiConfig.endpoints.refreshUpdates, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
folder_path: folderPath,
|
||||
force
|
||||
})
|
||||
});
|
||||
|
||||
let payload = {};
|
||||
try {
|
||||
payload = await response.json();
|
||||
} catch (error) {
|
||||
console.warn('Unable to parse refresh updates response as JSON', error);
|
||||
}
|
||||
|
||||
if (!response.ok || payload?.success !== true) {
|
||||
if (payload?.status === 'cancelled') {
|
||||
showToast('toast.api.operationCancelled', {}, 'info');
|
||||
return null;
|
||||
}
|
||||
const message = payload?.error || response.statusText || 'Failed to refresh updates';
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
return payload;
|
||||
} catch (error) {
|
||||
console.error('Error refreshing updates for folder:', error);
|
||||
throw error;
|
||||
} finally {
|
||||
state.loadingManager.hide();
|
||||
}
|
||||
}
|
||||
|
||||
async fetchCivitaiVersions(modelId, source = null) {
|
||||
try {
|
||||
let requestUrl = `${this.apiConfig.endpoints.civitaiVersions}/${modelId}`;
|
||||
@@ -909,7 +952,7 @@ export class BaseModelApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
async downloadModel(modelId, versionId, modelRoot, relativePath, useDefaultPaths = false, downloadId, source = null) {
|
||||
async downloadModel(modelId, versionId, modelRoot, relativePath, useDefaultPaths = false, downloadId, source = null, fileParams = null) {
|
||||
try {
|
||||
const response = await fetch(DOWNLOAD_ENDPOINTS.download, {
|
||||
method: 'POST',
|
||||
@@ -921,7 +964,8 @@ export class BaseModelApiClient {
|
||||
relative_path: relativePath,
|
||||
use_default_paths: useDefaultPaths,
|
||||
download_id: downloadId,
|
||||
...(source ? { source } : {})
|
||||
...(source ? { source } : {}),
|
||||
...(fileParams ? { file_params: fileParams } : {})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { translate } from '../utils/i18nHelpers.js';
|
||||
import { state } from '../state/index.js';
|
||||
import { bulkManager } from '../managers/BulkManager.js';
|
||||
import { showToast } from '../utils/uiHelpers.js';
|
||||
import { performFolderUpdateCheck } from '../utils/updateCheckHelpers.js';
|
||||
import { escapeHtml, escapeAttribute } from './shared/utils.js';
|
||||
|
||||
export class SidebarManager {
|
||||
@@ -41,6 +42,7 @@ export class SidebarManager {
|
||||
|
||||
// Bind methods
|
||||
this.handleTreeClick = this.handleTreeClick.bind(this);
|
||||
this.handleTreeContextMenu = this.handleTreeContextMenu.bind(this);
|
||||
this.handleBreadcrumbClick = this.handleBreadcrumbClick.bind(this);
|
||||
this.handleDocumentClick = this.handleDocumentClick.bind(this);
|
||||
this.handleSidebarHeaderClick = this.handleSidebarHeaderClick.bind(this);
|
||||
@@ -185,6 +187,8 @@ export class SidebarManager {
|
||||
}
|
||||
if (folderTree) {
|
||||
folderTree.removeEventListener('click', this.handleTreeClick);
|
||||
folderTree.removeEventListener('contextmenu', this.handleTreeContextMenu);
|
||||
folderTree.removeEventListener('dragover', this.handleFolderDragOver);
|
||||
}
|
||||
if (sidebarBreadcrumbNav) {
|
||||
sidebarBreadcrumbNav.removeEventListener('click', this.handleBreadcrumbClick);
|
||||
@@ -977,6 +981,7 @@ export class SidebarManager {
|
||||
const folderTree = document.getElementById('sidebarFolderTree');
|
||||
if (folderTree) {
|
||||
folderTree.addEventListener('click', this.handleTreeClick);
|
||||
folderTree.addEventListener('contextmenu', this.handleTreeContextMenu);
|
||||
}
|
||||
|
||||
// Breadcrumb click handler
|
||||
@@ -1027,6 +1032,19 @@ export class SidebarManager {
|
||||
if (displayModeToggleBtn) {
|
||||
displayModeToggleBtn.addEventListener('click', this.handleDisplayModeToggle);
|
||||
}
|
||||
|
||||
// Sidebar folder context menu click handler
|
||||
const sidebarFolderMenu = document.getElementById('sidebarFolderContextMenu');
|
||||
if (sidebarFolderMenu) {
|
||||
sidebarFolderMenu.addEventListener('click', (e) => {
|
||||
const item = e.target.closest('.context-menu-item');
|
||||
if (!item) return;
|
||||
const action = item.dataset.action;
|
||||
if (action) {
|
||||
this.handleFolderContextMenuAction(action);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleDocumentClick(event) {
|
||||
@@ -1398,6 +1416,82 @@ export class SidebarManager {
|
||||
}
|
||||
}
|
||||
|
||||
handleTreeContextMenu(event) {
|
||||
const nodeContent = event.target.closest('.sidebar-tree-node, .sidebar-folder-item');
|
||||
if (!nodeContent) return;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const path = nodeContent.dataset.path;
|
||||
if (path === undefined || path === null || path === '') return;
|
||||
|
||||
this._showFolderContextMenu(event.clientX, event.clientY, path);
|
||||
}
|
||||
|
||||
_showFolderContextMenu(x, y, path) {
|
||||
this._closeFolderContextMenu();
|
||||
|
||||
const menu = document.getElementById('sidebarFolderContextMenu');
|
||||
if (!menu) return;
|
||||
|
||||
menu.style.left = `${x}px`;
|
||||
menu.style.top = `${y}px`;
|
||||
menu.style.display = 'block';
|
||||
menu.dataset.folderPath = path;
|
||||
|
||||
this._folderContextOpen = true;
|
||||
|
||||
// Close on next click outside
|
||||
this._folderContextCloseHandler = (e) => {
|
||||
if (!menu.contains(e.target)) {
|
||||
this._closeFolderContextMenu();
|
||||
}
|
||||
};
|
||||
setTimeout(() => {
|
||||
document.addEventListener('click', this._folderContextCloseHandler);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
_closeFolderContextMenu() {
|
||||
const menu = document.getElementById('sidebarFolderContextMenu');
|
||||
if (menu) {
|
||||
menu.style.display = 'none';
|
||||
delete menu.dataset.folderPath;
|
||||
}
|
||||
if (this._folderContextCloseHandler) {
|
||||
document.removeEventListener('click', this._folderContextCloseHandler);
|
||||
this._folderContextCloseHandler = null;
|
||||
}
|
||||
this._folderContextOpen = false;
|
||||
}
|
||||
|
||||
handleFolderContextMenuAction(action) {
|
||||
const menu = document.getElementById('sidebarFolderContextMenu');
|
||||
if (!menu) return;
|
||||
|
||||
const path = menu.dataset.folderPath;
|
||||
this._closeFolderContextMenu();
|
||||
|
||||
if (!path) return;
|
||||
|
||||
this._performFolderAction(action, path);
|
||||
}
|
||||
|
||||
async _performFolderAction(action, path) {
|
||||
switch (action) {
|
||||
case 'check-folder-updates':
|
||||
try {
|
||||
await performFolderUpdateCheck(path);
|
||||
} catch (error) {
|
||||
console.error('Folder update check failed:', error);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.warn('Unknown folder action:', action);
|
||||
}
|
||||
}
|
||||
|
||||
handleBreadcrumbClick(event) {
|
||||
const breadcrumbItem = event.target.closest('.sidebar-breadcrumb-item');
|
||||
const dropdownItem = event.target.closest('.breadcrumb-dropdown-item');
|
||||
|
||||
@@ -33,6 +33,8 @@ export class DownloadManager {
|
||||
this.handleStartDownload = this.startDownload.bind(this);
|
||||
this.handleBackToUrl = this.backToUrl.bind(this);
|
||||
this.handleBackToVersions = this.backToVersions.bind(this);
|
||||
this.handleBackToVersionFromFiles = this.backToVersionFromFiles.bind(this);
|
||||
this.handleConfirmFileSelection = this.confirmFileSelection.bind(this);
|
||||
this.handleCloseModal = this.closeModal.bind(this);
|
||||
this.handleToggleDefaultPath = this.toggleDefaultPath.bind(this);
|
||||
}
|
||||
@@ -80,6 +82,10 @@ export class DownloadManager {
|
||||
document.getElementById('backToVersionsBtn').addEventListener('click', this.handleBackToVersions);
|
||||
document.getElementById('closeDownloadModal').addEventListener('click', this.handleCloseModal);
|
||||
|
||||
// File selection step buttons
|
||||
document.getElementById('backToVersionFromFilesBtn').addEventListener('click', this.handleBackToVersionFromFiles);
|
||||
document.getElementById('confirmFileSelection').addEventListener('click', this.handleConfirmFileSelection);
|
||||
|
||||
// Default path toggle handler
|
||||
document.getElementById('useDefaultPath').addEventListener('change', this.handleToggleDefaultPath);
|
||||
}
|
||||
@@ -129,6 +135,7 @@ export class DownloadManager {
|
||||
this.modelId = null;
|
||||
this.modelVersionId = null;
|
||||
this.source = null;
|
||||
this.selectedFile = null;
|
||||
|
||||
this.selectedFolder = '';
|
||||
|
||||
@@ -247,9 +254,12 @@ export class DownloadManager {
|
||||
const firstImage = version.images?.find(img => !img.url.endsWith('.mp4'));
|
||||
const thumbnailUrl = firstImage ? firstImage.url : '/loras_static/images/no-preview.png';
|
||||
|
||||
// Count model-type files per version
|
||||
const modelFiles = (version.files || []).filter(f => f.type === 'Model');
|
||||
const primaryFile = modelFiles.find(f => f.primary) || modelFiles[0] || {};
|
||||
const fileSize = version.modelSizeKB ?
|
||||
(version.modelSizeKB / 1024).toFixed(2) :
|
||||
(version.files[0]?.sizeKB / 1024).toFixed(2);
|
||||
((primaryFile.sizeKB || 0) / 1024).toFixed(2);
|
||||
|
||||
const existsLocally = version.existsLocally;
|
||||
const hasBeenDownloaded = version.hasBeenDownloaded && !existsLocally;
|
||||
@@ -282,6 +292,12 @@ export class DownloadManager {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
const fileBadge = modelFiles.length > 1 && !existsLocally
|
||||
? `<span class="file-select-badge" data-version-id="${version.id}">
|
||||
<i class="fas fa-th-list"></i> ${modelFiles.length} ${translate('modals.download.fileSelection.files')} <i class="fas fa-chevron-right badge-arrow"></i>
|
||||
</span>`
|
||||
: '';
|
||||
|
||||
return `
|
||||
<div class="version-item ${this.currentVersion?.id === version.id ? 'selected' : ''}
|
||||
${existsLocally ? 'exists-locally' : ''}
|
||||
@@ -302,14 +318,23 @@ export class DownloadManager {
|
||||
<div class="version-meta">
|
||||
<span><i class="fas fa-calendar"></i> ${new Date(version.createdAt).toLocaleDateString()}</span>
|
||||
<span><i class="fas fa-file-archive"></i> ${fileSize} MB</span>
|
||||
${fileBadge}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
// Add click handlers for version selection
|
||||
// Add click handlers for version selection and file badge
|
||||
versionList.addEventListener('click', (event) => {
|
||||
const badge = event.target.closest('.file-select-badge');
|
||||
if (badge) {
|
||||
event.stopPropagation();
|
||||
const versionId = badge.dataset.versionId;
|
||||
this.selectVersion(versionId);
|
||||
this.showFileSelectionStep(versionId);
|
||||
return;
|
||||
}
|
||||
const versionItem = event.target.closest('.version-item');
|
||||
if (versionItem) {
|
||||
this.selectVersion(versionItem.dataset.versionId);
|
||||
@@ -352,6 +377,80 @@ export class DownloadManager {
|
||||
}
|
||||
}
|
||||
|
||||
showFileSelectionStep(versionId) {
|
||||
const version = this.versions.find(v => v.id.toString() === versionId.toString());
|
||||
if (!version) return;
|
||||
|
||||
this.currentVersion = version;
|
||||
const modelFiles = (version.files || []).filter(f => f.type === 'Model');
|
||||
|
||||
document.getElementById('versionStep').style.display = 'none';
|
||||
document.getElementById('fileSelectionStep').style.display = 'block';
|
||||
|
||||
const nameEl = document.getElementById('fileSelectionVersionName');
|
||||
if (nameEl) {
|
||||
nameEl.textContent = `${version.name} · ${version.baseModel || ''}`;
|
||||
}
|
||||
|
||||
const container = document.getElementById('fileSelectionList');
|
||||
container.innerHTML = modelFiles.map(file => {
|
||||
const meta = file.metadata || {};
|
||||
const sizeGB = file.sizeKB ? (file.sizeKB / (1024 * 1024)).toFixed(2) : '--';
|
||||
const isSelected = this.selectedFile?.id === file.id;
|
||||
|
||||
const tags = [];
|
||||
if (meta.size) tags.push(`<span class="file-tag size">${meta.size}</span>`);
|
||||
if (meta.format) tags.push(`<span class="file-tag format">${meta.format}</span>`);
|
||||
if (meta.fp) tags.push(`<span class="file-tag fp">${meta.fp}</span>`);
|
||||
|
||||
const fileName = file.name || '';
|
||||
|
||||
return `
|
||||
<div class="file-option ${isSelected ? 'selected' : ''}" data-file-id="${file.id}">
|
||||
<div class="file-option-radio">
|
||||
<input type="radio" name="fileSelection" value="${file.id}" ${isSelected ? 'checked' : ''}>
|
||||
</div>
|
||||
<div class="file-option-info">
|
||||
<div class="file-option-tags">
|
||||
${tags.join(' ')}
|
||||
</div>
|
||||
<div class="file-option-name">${fileName}</div>
|
||||
</div>
|
||||
<div class="file-option-size">${sizeGB} GB</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
container.querySelectorAll('.file-option').forEach(el => {
|
||||
el.addEventListener('click', () => {
|
||||
container.querySelectorAll('.file-option').forEach(o => o.classList.remove('selected'));
|
||||
el.classList.add('selected');
|
||||
const radio = el.querySelector('input[type="radio"]');
|
||||
if (radio) radio.checked = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
confirmFileSelection() {
|
||||
const selectedRadio = document.querySelector('#fileSelectionList input[type="radio"]:checked');
|
||||
if (!selectedRadio) return;
|
||||
|
||||
const version = this.currentVersion;
|
||||
if (!version) return;
|
||||
|
||||
const modelFiles = (version.files || []).filter(f => f.type === 'Model');
|
||||
this.selectedFile = modelFiles.find(f => f.id.toString() === selectedRadio.value);
|
||||
|
||||
document.getElementById('fileSelectionStep').style.display = 'none';
|
||||
document.getElementById('locationStep').style.display = 'block';
|
||||
this.proceedToLocationContent();
|
||||
}
|
||||
|
||||
backToVersionFromFiles() {
|
||||
document.getElementById('fileSelectionStep').style.display = 'none';
|
||||
document.getElementById('versionStep').style.display = 'block';
|
||||
}
|
||||
|
||||
async proceedToLocation() {
|
||||
if (!this.currentVersion) {
|
||||
showToast('toast.loras.pleaseSelectVersion', {}, 'error');
|
||||
@@ -366,6 +465,10 @@ export class DownloadManager {
|
||||
|
||||
document.getElementById('versionStep').style.display = 'none';
|
||||
document.getElementById('locationStep').style.display = 'block';
|
||||
await this.proceedToLocationContent();
|
||||
}
|
||||
|
||||
async proceedToLocationContent() {
|
||||
|
||||
try {
|
||||
// Fetch model roots
|
||||
@@ -450,6 +553,7 @@ export class DownloadManager {
|
||||
targetFolder = '',
|
||||
useDefaultPaths = false,
|
||||
source = null,
|
||||
fileParams = null,
|
||||
closeModal = false,
|
||||
}) {
|
||||
const config = this.apiClient?.apiConfig?.config;
|
||||
@@ -513,7 +617,8 @@ export class DownloadManager {
|
||||
targetFolder,
|
||||
useDefaultPaths,
|
||||
downloadId,
|
||||
source
|
||||
source,
|
||||
fileParams
|
||||
);
|
||||
|
||||
if (response?.skipped) {
|
||||
@@ -632,6 +737,13 @@ export class DownloadManager {
|
||||
} else {
|
||||
targetFolder = this.folderTreeManager.getSelectedPath();
|
||||
}
|
||||
const fileParams = this.selectedFile ? {
|
||||
type: 'Model',
|
||||
format: this.selectedFile.metadata?.format || 'SafeTensor',
|
||||
size: this.selectedFile.metadata?.size || 'full',
|
||||
fp: this.selectedFile.metadata?.fp,
|
||||
} : null;
|
||||
|
||||
return this.executeDownloadWithProgress({
|
||||
modelId: this.modelId,
|
||||
versionId: this.currentVersion.id,
|
||||
@@ -640,6 +752,7 @@ export class DownloadManager {
|
||||
targetFolder,
|
||||
useDefaultPaths,
|
||||
source: this.source,
|
||||
fileParams,
|
||||
closeModal: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,6 +100,90 @@ export async function performModelUpdateCheck({ onStart, onComplete } = {}) {
|
||||
return { status, displayName, records, error };
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a model update check scoped to a specific folder.
|
||||
* @param {string} folderPath - The relative folder path to check.
|
||||
* @param {Object} [options]
|
||||
* @param {Function} [options.onComplete] - Callback invoked after the request settles.
|
||||
* @returns {Promise<{status: string, records: Array, error: Error | null}>}
|
||||
*/
|
||||
export async function performFolderUpdateCheck(folderPath, { onComplete } = {}) {
|
||||
const modelType = getCurrentModelType();
|
||||
const apiConfig = getCompleteApiConfig(modelType);
|
||||
const apiClient = getModelApiClient(modelType);
|
||||
const displayName = apiConfig?.config?.displayName ?? 'Model';
|
||||
|
||||
if (!apiConfig?.endpoints?.refreshUpdates) {
|
||||
console.warn('Refresh updates endpoint not configured for model type:', modelType);
|
||||
onComplete?.({ status: 'unsupported', records: [], error: null });
|
||||
return { status: 'unsupported', records: [], error: null };
|
||||
}
|
||||
|
||||
const loadingMessage = translate(
|
||||
'sidebar.folderUpdateCheck.loading',
|
||||
{ type: displayName },
|
||||
`Checking ${displayName} updates for this folder...`
|
||||
);
|
||||
|
||||
state.loadingManager?.showSimpleLoading?.(loadingMessage);
|
||||
state.loadingManager?.showCancelButton?.(() => apiClient.cancelTask());
|
||||
|
||||
let status = 'success';
|
||||
let records = [];
|
||||
let error = null;
|
||||
|
||||
try {
|
||||
const response = await fetch(apiConfig.endpoints.refreshUpdates, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ folder_path: folderPath, force: false })
|
||||
});
|
||||
|
||||
let payload = {};
|
||||
try {
|
||||
payload = await response.json();
|
||||
} catch {
|
||||
payload = {};
|
||||
}
|
||||
|
||||
if (!response.ok || payload.success !== true) {
|
||||
if (payload?.status === 'cancelled') {
|
||||
showToast('toast.api.operationCancelled', {}, 'info');
|
||||
return { status: 'cancelled', records: [], error: null };
|
||||
}
|
||||
const errorMessage = payload?.error || response.statusText || 'Unknown error';
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
records = Array.isArray(payload.records) ? payload.records : [];
|
||||
|
||||
if (records.length > 0) {
|
||||
showToast('sidebar.folderUpdateCheck.success', { count: records.length, type: displayName }, 'success');
|
||||
} else {
|
||||
showToast('sidebar.folderUpdateCheck.none', { type: displayName }, 'info');
|
||||
}
|
||||
|
||||
await resetAndReload(false);
|
||||
} catch (err) {
|
||||
status = 'error';
|
||||
error = err instanceof Error ? err : new Error(String(err));
|
||||
console.error('Error checking folder model updates:', error);
|
||||
showToast(
|
||||
'sidebar.folderUpdateCheck.error',
|
||||
{ message: error?.message ?? 'Unknown error', type: displayName },
|
||||
'error'
|
||||
);
|
||||
} finally {
|
||||
state.loadingManager?.hide?.();
|
||||
if (typeof state.loadingManager?.restoreProgressBar === 'function') {
|
||||
state.loadingManager.restoreProgressBar();
|
||||
}
|
||||
onComplete?.({ status, records, error });
|
||||
}
|
||||
|
||||
return { status, records, error };
|
||||
}
|
||||
|
||||
function getTypePlural(displayName) {
|
||||
if (!displayName) {
|
||||
return 'models';
|
||||
|
||||
@@ -150,6 +150,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sidebar Folder Context Menu -->
|
||||
<div id="sidebarFolderContextMenu" class="context-menu">
|
||||
<div class="context-menu-item" data-action="check-folder-updates">
|
||||
<i class="fas fa-bell"></i> <span>{{ t('sidebar.folderUpdateCheck.label') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="nsfwLevelSelector" class="nsfw-level-selector">
|
||||
<div class="nsfw-level-header">
|
||||
<h3>{{ t('modals.contentRating.title') }}</h3>
|
||||
|
||||
@@ -29,6 +29,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 2.5: File Selection (optional - only when version has multiple model files) -->
|
||||
<div class="download-step" id="fileSelectionStep" style="display: none;">
|
||||
<div class="file-selection-header">
|
||||
<h3 id="fileSelectionTitle">{{ t('modals.download.fileSelection.title') }}</h3>
|
||||
<div class="file-selection-version-name" id="fileSelectionVersionName"></div>
|
||||
</div>
|
||||
<div class="file-selection-list" id="fileSelectionList">
|
||||
<!-- File options will be rendered here dynamically -->
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="secondary-btn" id="backToVersionFromFilesBtn">{{ t('common.actions.back') }}</button>
|
||||
<button class="primary-btn" id="confirmFileSelection">{{ t('modals.download.fileSelection.select') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Location Selection -->
|
||||
<div class="download-step" id="locationStep" style="display: none;">
|
||||
<div class="location-selection">
|
||||
|
||||
@@ -46,6 +46,7 @@ class DummyUpdateService:
|
||||
*,
|
||||
force_refresh=False,
|
||||
target_model_ids=None,
|
||||
folder_path=None,
|
||||
):
|
||||
self.calls.append(
|
||||
{
|
||||
@@ -54,6 +55,7 @@ class DummyUpdateService:
|
||||
"provider": provider,
|
||||
"force_refresh": force_refresh,
|
||||
"target_model_ids": target_model_ids,
|
||||
"folder_path": folder_path,
|
||||
}
|
||||
)
|
||||
return self.records
|
||||
|
||||
Reference in New Issue
Block a user