mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
feat(localization): enhance toast messages for API actions and model management with i18n support
refactor(localization): update toast messages in various components and managers for better user feedback
This commit is contained in:
@@ -76,7 +76,7 @@ export class BaseModelApiClient {
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error fetching ${this.apiConfig.config.displayName}s:`, error);
|
||||
showToast(`Failed to fetch ${this.apiConfig.config.displayName}s: ${error.message}`, 'error');
|
||||
showToast('toast.api.fetchFailed', { type: this.apiConfig.config.displayName, message: error.message }, 'error');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ export class BaseModelApiClient {
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error(`Error reloading ${this.apiConfig.config.displayName}s:`, error);
|
||||
showToast(`Failed to reload ${this.apiConfig.config.displayName}s: ${error.message}`, 'error');
|
||||
showToast('toast.api.reloadFailed', { type: this.apiConfig.config.displayName, message: error.message }, 'error');
|
||||
throw error;
|
||||
} finally {
|
||||
pageState.isLoading = false;
|
||||
@@ -138,14 +138,14 @@ export class BaseModelApiClient {
|
||||
if (state.virtualScroller) {
|
||||
state.virtualScroller.removeItemByFilePath(filePath);
|
||||
}
|
||||
showToast(`${this.apiConfig.config.displayName} deleted successfully`, 'success');
|
||||
showToast('toast.api.deleteSuccess', { type: this.apiConfig.config.displayName }, 'success');
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(data.error || `Failed to delete ${this.apiConfig.config.singularName}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error deleting ${this.apiConfig.config.singularName}:`, error);
|
||||
showToast(`Failed to delete ${this.apiConfig.config.singularName}: ${error.message}`, 'error');
|
||||
showToast('toast.api.deleteFailed', { type: this.apiConfig.config.singularName, message: error.message }, 'error');
|
||||
return false;
|
||||
} finally {
|
||||
state.loadingManager.hide();
|
||||
@@ -172,14 +172,14 @@ export class BaseModelApiClient {
|
||||
if (state.virtualScroller) {
|
||||
state.virtualScroller.removeItemByFilePath(filePath);
|
||||
}
|
||||
showToast(`${this.apiConfig.config.displayName} excluded successfully`, 'success');
|
||||
showToast('toast.api.excludeSuccess', { type: this.apiConfig.config.displayName }, 'success');
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(data.error || `Failed to exclude ${this.apiConfig.config.singularName}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error excluding ${this.apiConfig.config.singularName}:`, error);
|
||||
showToast(`Failed to exclude ${this.apiConfig.config.singularName}: ${error.message}`, 'error');
|
||||
showToast('toast.api.excludeFailed', { type: this.apiConfig.config.singularName, message: error.message }, 'error');
|
||||
return false;
|
||||
} finally {
|
||||
state.loadingManager.hide();
|
||||
@@ -208,9 +208,9 @@ export class BaseModelApiClient {
|
||||
preview_url: result.new_preview_path
|
||||
});
|
||||
|
||||
showToast('File name updated successfully', 'success');
|
||||
showToast('toast.api.fileNameUpdated', {}, 'success');
|
||||
} else {
|
||||
showToast('Failed to rename file: ' + (result.error || 'Unknown error'), 'error');
|
||||
showToast('toast.api.fileRenameFailed', { error: result.error || 'Unknown error' }, 'error');
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -272,10 +272,10 @@ export class BaseModelApiClient {
|
||||
};
|
||||
|
||||
state.virtualScroller.updateSingleItem(filePath, updateData);
|
||||
showToast('Preview updated successfully', 'success');
|
||||
showToast('toast.api.previewUpdated', {}, 'success');
|
||||
} catch (error) {
|
||||
console.error('Error uploading preview:', error);
|
||||
showToast('Failed to upload preview image', 'error');
|
||||
showToast('toast.api.previewUploadFailed', {}, 'error');
|
||||
} finally {
|
||||
state.loadingManager.hide();
|
||||
}
|
||||
@@ -322,10 +322,10 @@ export class BaseModelApiClient {
|
||||
|
||||
resetAndReload(true);
|
||||
|
||||
showToast(`${fullRebuild ? 'Full rebuild' : 'Refresh'} complete`, 'success');
|
||||
showToast('toast.api.refreshComplete', { action: fullRebuild ? 'Full rebuild' : 'Refresh' }, 'success');
|
||||
} catch (error) {
|
||||
console.error('Refresh failed:', error);
|
||||
showToast(`Failed to ${fullRebuild ? 'rebuild' : 'refresh'} ${this.apiConfig.config.displayName}s`, 'error');
|
||||
showToast('toast.api.refreshFailed', { action: fullRebuild ? 'rebuild' : 'refresh', type: this.apiConfig.config.displayName }, 'error');
|
||||
} finally {
|
||||
state.loadingManager.hide();
|
||||
state.loadingManager.restoreProgressBar();
|
||||
@@ -353,14 +353,14 @@ export class BaseModelApiClient {
|
||||
state.virtualScroller.updateSingleItem(filePath, data.metadata);
|
||||
}
|
||||
|
||||
showToast('Metadata refreshed successfully', 'success');
|
||||
showToast('toast.api.metadataRefreshed', {}, 'success');
|
||||
return true;
|
||||
} else {
|
||||
throw new Error(data.error || 'Failed to refresh metadata');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error refreshing metadata:', error);
|
||||
showToast(error.message, 'error');
|
||||
showToast('toast.api.metadataRefreshFailed', { message: error.message }, 'error');
|
||||
return false;
|
||||
} finally {
|
||||
state.loadingManager.hide();
|
||||
@@ -432,10 +432,10 @@ export class BaseModelApiClient {
|
||||
await operationComplete;
|
||||
|
||||
resetAndReload(false);
|
||||
showToast('Metadata update complete', 'success');
|
||||
showToast('toast.api.metadataUpdateComplete', {}, 'success');
|
||||
} catch (error) {
|
||||
console.error('Error fetching metadata:', error);
|
||||
showToast('Failed to fetch metadata: ' + error.message, 'error');
|
||||
showToast('toast.api.metadataFetchFailed', { message: error.message }, 'error');
|
||||
} finally {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
@@ -534,7 +534,7 @@ export class BaseModelApiClient {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error in bulk metadata refresh:', error);
|
||||
showToast(`Failed to refresh metadata: ${error.message}`, 'error');
|
||||
showToast('toast.api.bulkMetadataFailed', { message: error.message }, 'error');
|
||||
await progressController.complete('Operation failed');
|
||||
throw error;
|
||||
}
|
||||
@@ -708,11 +708,11 @@ export class BaseModelApiClient {
|
||||
async moveSingleModel(filePath, targetPath) {
|
||||
// Only allow move if supported
|
||||
if (!this.apiConfig.config.supportsMove) {
|
||||
showToast(`Moving ${this.apiConfig.config.displayName}s is not supported`, 'warning');
|
||||
showToast('toast.api.moveNotSupported', { type: this.apiConfig.config.displayName }, 'warning');
|
||||
return null;
|
||||
}
|
||||
if (filePath.substring(0, filePath.lastIndexOf('/')) === targetPath) {
|
||||
showToast(`${this.apiConfig.config.displayName} is already in the selected folder`, 'info');
|
||||
showToast('toast.api.alreadyInFolder', { type: this.apiConfig.config.displayName }, 'info');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -737,9 +737,9 @@ export class BaseModelApiClient {
|
||||
}
|
||||
|
||||
if (result && result.message) {
|
||||
showToast(result.message, 'info');
|
||||
showToast('toast.api.moveInfo', { message: result.message }, 'info');
|
||||
} else {
|
||||
showToast(`${this.apiConfig.config.displayName} moved successfully`, 'success');
|
||||
showToast('toast.api.moveSuccess', { type: this.apiConfig.config.displayName }, 'success');
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
@@ -753,7 +753,7 @@ export class BaseModelApiClient {
|
||||
|
||||
async moveBulkModels(filePaths, targetPath) {
|
||||
if (!this.apiConfig.config.supportsMove) {
|
||||
showToast(`Moving ${this.apiConfig.config.displayName}s is not supported`, 'warning');
|
||||
showToast('toast.api.bulkMoveNotSupported', { type: this.apiConfig.config.displayName }, 'warning');
|
||||
return [];
|
||||
}
|
||||
const movedPaths = filePaths.filter(path => {
|
||||
@@ -761,7 +761,7 @@ export class BaseModelApiClient {
|
||||
});
|
||||
|
||||
if (movedPaths.length === 0) {
|
||||
showToast(`All selected ${this.apiConfig.config.displayName}s are already in the target folder`, 'info');
|
||||
showToast('toast.api.allAlreadyInFolder', { type: this.apiConfig.config.displayName }, 'info');
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -784,7 +784,11 @@ export class BaseModelApiClient {
|
||||
|
||||
if (result.success) {
|
||||
if (result.failure_count > 0) {
|
||||
showToast(`Moved ${result.success_count} ${this.apiConfig.config.displayName}s, ${result.failure_count} failed`, 'warning');
|
||||
showToast('toast.api.bulkMovePartial', {
|
||||
successCount: result.success_count,
|
||||
type: this.apiConfig.config.displayName,
|
||||
failureCount: result.failure_count
|
||||
}, 'warning');
|
||||
console.log('Move operation results:', result.results);
|
||||
const failedFiles = result.results
|
||||
.filter(r => !r.success)
|
||||
@@ -796,10 +800,13 @@ export class BaseModelApiClient {
|
||||
const failureMessage = failedFiles.length <= 3
|
||||
? failedFiles.join('\n')
|
||||
: failedFiles.slice(0, 3).join('\n') + `\n(and ${failedFiles.length - 3} more)`;
|
||||
showToast(`Failed moves:\n${failureMessage}`, 'warning', 6000);
|
||||
showToast('toast.api.bulkMoveFailures', { failures: failureMessage }, 'warning', 6000);
|
||||
}
|
||||
} else {
|
||||
showToast(`Successfully moved ${result.success_count} ${this.apiConfig.config.displayName}s`, 'success');
|
||||
showToast('toast.api.bulkMoveSuccess', {
|
||||
successCount: result.success_count,
|
||||
type: this.apiConfig.config.displayName
|
||||
}, 'success');
|
||||
}
|
||||
|
||||
// Return the results array with original_file_path and new_file_path
|
||||
@@ -931,12 +938,12 @@ export class BaseModelApiClient {
|
||||
// Wait for the operation to complete via WebSocket
|
||||
await operationComplete;
|
||||
|
||||
showToast('Successfully downloaded example images!', 'success');
|
||||
showToast('toast.api.exampleImagesDownloadSuccess', {}, 'success');
|
||||
return true;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error downloading example images:', error);
|
||||
showToast(`Failed to download example images: ${error.message}`, 'error');
|
||||
showToast('toast.api.exampleImagesDownloadFailed', { message: error.message }, 'error');
|
||||
throw error;
|
||||
} finally {
|
||||
if (ws) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { BaseModelApiClient } from './baseModelApi.js';
|
||||
import { showToast } from '../utils/uiHelpers.js';
|
||||
|
||||
/**
|
||||
* Checkpoint-specific API client
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { BaseModelApiClient } from './baseModelApi.js';
|
||||
import { showToast } from '../utils/uiHelpers.js';
|
||||
|
||||
/**
|
||||
* Embedding-specific API client
|
||||
|
||||
@@ -47,7 +47,7 @@ export class CheckpointsControls extends PageControls {
|
||||
// No clearCustomFilter implementation is needed for checkpoints
|
||||
// as custom filters are currently only used for LoRAs
|
||||
clearCustomFilter: async () => {
|
||||
showToast('No custom filter to clear', 'info');
|
||||
showToast('toast.filters.noCustomFilterToClear', {}, 'info');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export class EmbeddingsControls extends PageControls {
|
||||
// No clearCustomFilter implementation is needed for embeddings
|
||||
// as custom filters are currently only used for LoRAs
|
||||
clearCustomFilter: async () => {
|
||||
showToast('No custom filter to clear', 'info');
|
||||
showToast('toast.filters.noCustomFilterToClear', {}, 'info');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -83,8 +83,7 @@ export function setupModelNameEditing(filePath) {
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
|
||||
const text = translate('modelMetadata.validation.nameTooLong', {}, 'Model name is limited to 100 characters');
|
||||
showToast(text, 'warning');
|
||||
showToast('toast.models.nameTooLong', {}, 'warning');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -99,7 +98,7 @@ export function setupModelNameEditing(filePath) {
|
||||
if (!newModelName) {
|
||||
// Restore original value if empty
|
||||
this.textContent = originalValue;
|
||||
showToast('Model name cannot be empty', 'error');
|
||||
showToast('toast.models.nameCannotBeEmpty', {}, 'error');
|
||||
exitEditMode();
|
||||
return;
|
||||
}
|
||||
@@ -116,11 +115,11 @@ export function setupModelNameEditing(filePath) {
|
||||
|
||||
await getModelApiClient().saveModelMetadata(filePath, { model_name: newModelName });
|
||||
|
||||
showToast('Model name updated successfully', 'success');
|
||||
showToast('toast.models.nameUpdatedSuccessfully', {}, 'success');
|
||||
} catch (error) {
|
||||
console.error('Error updating model name:', error);
|
||||
this.textContent = originalValue; // Restore original model name
|
||||
showToast('Failed to update model name', 'error');
|
||||
showToast('toast.models.nameUpdateFailed', {}, 'error');
|
||||
} finally {
|
||||
exitEditMode();
|
||||
}
|
||||
@@ -302,9 +301,9 @@ async function saveBaseModel(filePath, originalValue) {
|
||||
try {
|
||||
await getModelApiClient().saveModelMetadata(filePath, { base_model: newBaseModel });
|
||||
|
||||
showToast('Base model updated successfully', 'success');
|
||||
showToast('toast.models.baseModelUpdated', {}, 'success');
|
||||
} catch (error) {
|
||||
showToast('Failed to update base model', 'error');
|
||||
showToast('toast.models.baseModelUpdateFailed', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +389,7 @@ export function setupFileNameEditing(filePath) {
|
||||
sel.addRange(range);
|
||||
}
|
||||
|
||||
showToast('Invalid characters removed from filename', 'warning');
|
||||
showToast('toast.models.invalidCharactersRemoved', {}, 'warning');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -405,7 +404,7 @@ export function setupFileNameEditing(filePath) {
|
||||
if (!newFileName) {
|
||||
// Restore original value if empty
|
||||
this.textContent = originalValue;
|
||||
showToast('File name cannot be empty', 'error');
|
||||
showToast('toast.models.filenameCannotBeEmpty', {}, 'error');
|
||||
exitEditMode();
|
||||
return;
|
||||
}
|
||||
@@ -424,7 +423,7 @@ export function setupFileNameEditing(filePath) {
|
||||
} catch (error) {
|
||||
console.error('Error renaming file:', error);
|
||||
this.textContent = originalValue; // Restore original file name
|
||||
showToast(`Failed to rename file: ${error.message}`, 'error');
|
||||
showToast('toast.models.renameFailed', { message: error.message }, 'error');
|
||||
} finally {
|
||||
exitEditMode();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ async function fetchTrainedWords(filePath) {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching trained words:', error);
|
||||
showToast('Could not load trained words', 'error');
|
||||
showToast('toast.triggerWords.loadFailed', {}, 'error');
|
||||
return { trainedWords: [], classTokens: null };
|
||||
}
|
||||
}
|
||||
@@ -499,21 +499,21 @@ function addNewTriggerWord(word) {
|
||||
|
||||
// Validation: Check length
|
||||
if (word.split(/\s+/).length > 30) {
|
||||
showToast('Trigger word should not exceed 30 words', 'error');
|
||||
showToast('toast.triggerWords.tooLong', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation: Check total number
|
||||
const currentTags = tagsContainer.querySelectorAll('.trigger-word-tag');
|
||||
if (currentTags.length >= 30) {
|
||||
showToast('Maximum 30 trigger words allowed', 'error');
|
||||
showToast('toast.triggerWords.tooMany', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation: Check for duplicates
|
||||
const existingWords = Array.from(currentTags).map(tag => tag.dataset.word);
|
||||
if (existingWords.includes(word)) {
|
||||
showToast('This trigger word already exists', 'error');
|
||||
showToast('toast.triggerWords.alreadyExists', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -628,10 +628,10 @@ async function saveTriggerWords() {
|
||||
if (tagsContainer) tagsContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
showToast('Trigger words updated successfully', 'success');
|
||||
showToast('toast.triggerWords.updateSuccess', {}, 'success');
|
||||
} catch (error) {
|
||||
console.error('Error saving trigger words:', error);
|
||||
showToast('Failed to update trigger words', 'error');
|
||||
showToast('toast.triggerWords.updateFailed', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,6 +644,6 @@ window.copyTriggerWord = async function(word) {
|
||||
await copyToClipboard(word, 'Trigger word copied');
|
||||
} catch (err) {
|
||||
console.error('Copy failed:', err);
|
||||
showToast('Copy failed', 'error');
|
||||
showToast('toast.triggerWords.copyFailed', {}, 'error');
|
||||
}
|
||||
};
|
||||
@@ -10,7 +10,7 @@ import { bulkManager } from './managers/BulkManager.js';
|
||||
import { exampleImagesManager } from './managers/ExampleImagesManager.js';
|
||||
import { helpManager } from './managers/HelpManager.js';
|
||||
import { bannerService } from './managers/BannerService.js';
|
||||
import { showToast, initTheme, initBackToTop } from './utils/uiHelpers.js';
|
||||
import { initTheme, initBackToTop } from './utils/uiHelpers.js';
|
||||
import { initializeInfiniteScroll } from './utils/infiniteScroll.js';
|
||||
import { migrateStorageItems } from './utils/storageHelpers.js';
|
||||
import { i18n } from './i18n/index.js';
|
||||
@@ -75,11 +75,6 @@ export class AppCore {
|
||||
return body.dataset.page || 'unknown';
|
||||
}
|
||||
|
||||
// Show toast messages
|
||||
showToast(key, params = {}, type = 'info') {
|
||||
showToast(key, params, type);
|
||||
}
|
||||
|
||||
// Initialize common UI features based on page type
|
||||
initializePageFeatures() {
|
||||
const pageType = this.getPageType();
|
||||
|
||||
@@ -350,11 +350,11 @@ export class BulkManager {
|
||||
|
||||
if (missingLoras.length > 0) {
|
||||
console.warn('Missing metadata for some selected loras:', missingLoras);
|
||||
showToast(`Missing data for ${missingLoras.length} LoRAs`, 'warning');
|
||||
showToast('toast.loras.missingDataForLoras', { count: missingLoras.length }, 'warning');
|
||||
}
|
||||
|
||||
if (loraSyntaxes.length === 0) {
|
||||
showToast('No valid LoRAs to send', 'error');
|
||||
showToast('toast.loras.noValidLorasToSend', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ export class BulkManager {
|
||||
|
||||
showBulkDeleteModal() {
|
||||
if (state.selectedModels.size === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ export class BulkManager {
|
||||
|
||||
async confirmBulkDelete() {
|
||||
if (state.selectedModels.size === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
modalManager.closeModal('bulkDeleteModal');
|
||||
return;
|
||||
}
|
||||
@@ -392,7 +392,10 @@ export class BulkManager {
|
||||
|
||||
if (result.success) {
|
||||
const currentConfig = MODEL_CONFIG[state.currentPageType];
|
||||
showToast(`Successfully deleted ${result.deleted_count} ${currentConfig.displayName.toLowerCase()}(s)`, 'success');
|
||||
showToast('toast.models.deletedSuccessfully', {
|
||||
count: result.deleted_count,
|
||||
type: currentConfig.displayName.toLowerCase()
|
||||
}, 'success');
|
||||
|
||||
filePaths.forEach(path => {
|
||||
state.virtualScroller.removeItemByFilePath(path);
|
||||
@@ -403,11 +406,11 @@ export class BulkManager {
|
||||
window.modelDuplicatesManager.updateDuplicatesBadgeAfterRefresh();
|
||||
}
|
||||
} else {
|
||||
showToast(`Error: ${result.error || 'Failed to delete models'}`, 'error');
|
||||
showToast('toast.models.deleteFailed', { error: result.error || 'Failed to delete models' }, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error during bulk delete:', error);
|
||||
showToast('Failed to delete models', 'error');
|
||||
showToast('toast.models.deleteFailedGeneral', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +541,7 @@ export class BulkManager {
|
||||
|
||||
selectAllVisibleModels() {
|
||||
if (!state.virtualScroller || !state.virtualScroller.items) {
|
||||
showToast('Unable to select all items', 'error');
|
||||
showToast('toast.bulk.unableToSelectAll', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -565,7 +568,10 @@ export class BulkManager {
|
||||
|
||||
const newlySelected = state.selectedModels.size - oldCount;
|
||||
const currentConfig = MODEL_CONFIG[state.currentPageType];
|
||||
showToast(`Selected ${newlySelected} additional ${currentConfig.displayName.toLowerCase()}(s)`, 'success');
|
||||
showToast('toast.models.selectedAdditional', {
|
||||
count: newlySelected,
|
||||
type: currentConfig.displayName.toLowerCase()
|
||||
}, 'success');
|
||||
|
||||
if (this.isStripVisible) {
|
||||
this.updateThumbnailStrip();
|
||||
@@ -574,7 +580,7 @@ export class BulkManager {
|
||||
|
||||
async refreshAllMetadata() {
|
||||
if (state.selectedModels.size === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -610,7 +616,7 @@ export class BulkManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error during bulk metadata refresh:', error);
|
||||
showToast('Failed to refresh metadata', 'error');
|
||||
showToast('toast.models.refreshMetadataFailed', {}, 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ export class FilterManager {
|
||||
await getModelApiClient().loadMoreWithVirtualScroll(true, true);
|
||||
}
|
||||
|
||||
showToast(`Filters cleared`, 'info');
|
||||
showToast('toast.filters.cleared', {}, 'info');
|
||||
}
|
||||
|
||||
loadFiltersFromStorage() {
|
||||
|
||||
@@ -261,7 +261,7 @@ export class ImportManager {
|
||||
|
||||
this.updateTargetPath();
|
||||
} catch (error) {
|
||||
showToast(error.message, 'error');
|
||||
showToast('toast.import.importFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,11 +350,11 @@ export class ImportManager {
|
||||
await this.folderTreeManager.loadTree(treeData.tree);
|
||||
} else {
|
||||
console.error('Failed to fetch folder tree:', treeData.error);
|
||||
showToast('Failed to load folder tree', 'error');
|
||||
showToast('toast.import.folderTreeFailed', {}, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error initializing folder tree:', error);
|
||||
showToast('Error loading folder tree', 'error');
|
||||
showToast('toast.import.folderTreeError', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class MoveManager {
|
||||
if (filePath === 'bulk') {
|
||||
const selectedPaths = Array.from(state.selectedModels);
|
||||
if (selectedPaths.length === 0) {
|
||||
showToast('No models selected', 'warning');
|
||||
showToast('toast.models.noModelsSelected', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
this.bulkFilePaths = selectedPaths;
|
||||
@@ -116,7 +116,7 @@ class MoveManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error fetching ${modelConfig.displayName.toLowerCase()} roots or folders:`, error);
|
||||
showToast(error.message, 'error');
|
||||
showToast('toast.models.moveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,11 +131,11 @@ class MoveManager {
|
||||
await this.folderTreeManager.loadTree(treeData.tree);
|
||||
} else {
|
||||
console.error('Failed to fetch folder tree:', treeData.error);
|
||||
showToast('Failed to load folder tree', 'error');
|
||||
showToast('toast.import.folderTreeFailed', {}, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error initializing folder tree:', error);
|
||||
showToast('Error loading folder tree', 'error');
|
||||
showToast('toast.import.folderTreeError', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class MoveManager {
|
||||
const config = apiClient.apiConfig.config;
|
||||
|
||||
if (!selectedRoot) {
|
||||
showToast(`Please select a ${config.displayName.toLowerCase()} root directory`, 'error');
|
||||
showToast('toast.models.pleaseSelectRoot', { type: config.displayName.toLowerCase() }, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ class MoveManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error moving model(s):', error);
|
||||
showToast('Failed to move model(s): ' + error.message, 'error');
|
||||
showToast('toast.models.moveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ export class SettingsManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading LoRA roots:', error);
|
||||
showToast('Failed to load LoRA roots: ' + error.message, 'error');
|
||||
showToast('toast.settings.loraRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ export class SettingsManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading checkpoint roots:', error);
|
||||
showToast('Failed to load checkpoint roots: ' + error.message, 'error');
|
||||
showToast('toast.settings.checkpointRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ export class SettingsManager {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading embedding roots:', error);
|
||||
showToast('Failed to load embedding roots: ' + error.message, 'error');
|
||||
showToast('toast.settings.embeddingRootsFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,14 +560,17 @@ export class SettingsManager {
|
||||
// Show success toast
|
||||
const mappingCount = Object.keys(state.global.settings.base_model_path_mappings).length;
|
||||
if (mappingCount > 0) {
|
||||
showToast(`Base model path mappings updated (${mappingCount} mapping${mappingCount !== 1 ? 's' : ''})`, 'success');
|
||||
showToast('toast.settings.mappingsUpdated', {
|
||||
count: mappingCount,
|
||||
plural: mappingCount !== 1 ? 's' : ''
|
||||
}, 'success');
|
||||
} else {
|
||||
showToast('Base model path mappings cleared', 'success');
|
||||
showToast('toast.settings.mappingsCleared', {}, 'success');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error saving base model mappings:', error);
|
||||
showToast('Failed to save base model mappings: ' + error.message, 'error');
|
||||
showToast('toast.settings.mappingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,11 +747,11 @@ export class SettingsManager {
|
||||
throw new Error('Failed to save download path templates');
|
||||
}
|
||||
|
||||
showToast('Download path templates updated', 'success');
|
||||
showToast('toast.settings.downloadTemplatesUpdated', {}, 'success');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error saving download path templates:', error);
|
||||
showToast('Failed to save download path templates: ' + error.message, 'error');
|
||||
showToast('toast.settings.downloadTemplatesFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +812,7 @@ export class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
showToast(`Settings updated: ${settingKey.replace(/_/g, ' ')}`, 'success');
|
||||
showToast('toast.settings.settingsUpdated', { setting: settingKey.replace(/_/g, ' ') }, 'success');
|
||||
|
||||
// Apply frontend settings immediately
|
||||
this.applyFrontendSettings();
|
||||
@@ -830,11 +833,13 @@ export class SettingsManager {
|
||||
// Recalculate layout when compact mode changes
|
||||
if (settingKey === 'compact_mode' && state.virtualScroller) {
|
||||
state.virtualScroller.calculateLayout();
|
||||
showToast(`Compact Mode ${value ? 'enabled' : 'disabled'}`, 'success');
|
||||
showToast('toast.settings.compactModeToggled', {
|
||||
state: value ? 'toast.settings.compactModeEnabled' : 'toast.settings.compactModeDisabled'
|
||||
}, 'success');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to save setting: ' + error.message, 'error');
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,7 +893,7 @@ export class SettingsManager {
|
||||
throw new Error('Failed to save setting');
|
||||
}
|
||||
|
||||
showToast(`Settings updated: ${settingKey.replace(/_/g, ' ')}`, 'success');
|
||||
showToast('toast.settings.settingsUpdated', { setting: settingKey.replace(/_/g, ' ') }, 'success');
|
||||
}
|
||||
|
||||
// Apply frontend settings immediately
|
||||
@@ -902,11 +907,11 @@ export class SettingsManager {
|
||||
if (value === 'medium') densityName = "Medium";
|
||||
if (value === 'compact') densityName = "Compact";
|
||||
|
||||
showToast(`Display Density set to ${densityName}`, 'success');
|
||||
showToast('toast.settings.displayDensitySet', { density: densityName }, 'success');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to save setting: ' + error.message, 'error');
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -945,10 +950,10 @@ export class SettingsManager {
|
||||
throw new Error('Failed to save setting');
|
||||
}
|
||||
|
||||
showToast(`Settings updated: ${settingKey.replace(/_/g, ' ')}`, 'success');
|
||||
showToast('toast.settings.settingsUpdated', { setting: settingKey.replace(/_/g, ' ') }, 'success');
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to save setting: ' + error.message, 'error');
|
||||
showToast('toast.settings.settingSaveFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,7 +989,7 @@ export class SettingsManager {
|
||||
window.location.reload();
|
||||
|
||||
} catch (error) {
|
||||
showToast('Failed to change language: ' + error.message, 'error');
|
||||
showToast('toast.settings.languageChangeFailed', { message: error.message }, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,15 +1024,15 @@ export class SettingsManager {
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
showToast('Cache files have been cleared successfully. Cache will rebuild on next action.', 'success');
|
||||
showToast('toast.settings.cacheCleared', {}, 'success');
|
||||
} else {
|
||||
showToast(`Failed to clear cache: ${result.error}`, 'error');
|
||||
showToast('toast.settings.cacheClearFailed', { error: result.error }, 'error');
|
||||
}
|
||||
|
||||
// Close the confirmation modal
|
||||
modalManager.closeModal('clearCacheModal');
|
||||
} catch (error) {
|
||||
showToast(`Error clearing cache: ${error.message}`, 'error');
|
||||
showToast('toast.settings.cacheClearError', { message: error.message }, 'error');
|
||||
modalManager.closeModal('clearCacheModal');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ export class ImageProcessor {
|
||||
|
||||
async uploadAndAnalyzeImage() {
|
||||
if (!this.importManager.recipeImage) {
|
||||
showToast('Please select an image first', 'error');
|
||||
showToast('toast.import.selectImageFirst', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ export class RecipeDataManager {
|
||||
proceedFromDetails() {
|
||||
// Validate recipe name
|
||||
if (!this.importManager.recipeName) {
|
||||
showToast('Please enter a recipe name', 'error');
|
||||
showToast('toast.import.enterRecipeName', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user