@@ -39,6 +39,10 @@ const newPathInput = document.getElementById('new-path');
3939const modelsList = document . getElementById ( 'models-list' ) ;
4040const modelsCount = document . getElementById ( 'models-count' ) ;
4141
42+ // Model-Type-Management DOM-Elemente
43+ const updateTypesButton = document . getElementById ( 'update-types-button' ) ;
44+ const newTypeInput = document . getElementById ( 'new-type' ) ;
45+
4246// Feste Werte für Tabelle und Spalte
4347const MODELS_TABLE = 'models' ;
4448const PATH_COLUMN = 'path' ;
@@ -371,6 +375,67 @@ updatePathsButton.addEventListener('click', async () => {
371375 }
372376} ) ;
373377
378+ // Event-Handler für Model-Type-Update
379+ updateTypesButton . addEventListener ( 'click' , async ( ) => {
380+ try {
381+ if ( ! dbPath ) {
382+ setStatus ( window . translations [ currentLanguage ] . noDbSelected || 'Bitte wählen Sie zuerst eine Datenbank aus.' , true ) ;
383+ return ;
384+ }
385+
386+ const newType = newTypeInput . value . trim ( ) ;
387+
388+ if ( ! newType ) {
389+ setStatus ( window . translations [ currentLanguage ] . newTypeRequired || 'Bitte geben Sie den neuen Type ein.' , true ) ;
390+ return ;
391+ }
392+
393+ // Sammle die ausgewählten Model-IDs
394+ const selectedModelIds = [ ] ;
395+ const checkboxes = document . querySelectorAll ( '.model-checkbox:checked' ) ;
396+
397+ checkboxes . forEach ( checkbox => {
398+ const index = parseInt ( checkbox . id . replace ( 'model-' , '' ) ) ;
399+ if ( modelsData [ index ] && modelsData [ index ] . id ) {
400+ selectedModelIds . push ( modelsData [ index ] . id ) ;
401+ }
402+ } ) ;
403+
404+ if ( selectedModelIds . length === 0 ) {
405+ setStatus ( window . translations [ currentLanguage ] . noModelsSelected || 'Bitte wählen Sie mindestens ein Model aus.' , true ) ;
406+ return ;
407+ }
408+
409+ // Bestätigungsdialog
410+ const confirmMessage = ( window . translations [ currentLanguage ] . confirmUpdateTypes || 'Möchten Sie wirklich den config-type von {count} ausgewählten Models zu "{newType}" ändern?' )
411+ . replace ( '{count}' , selectedModelIds . length )
412+ . replace ( '{newType}' , newType ) ;
413+
414+ if ( ! confirm ( confirmMessage ) ) {
415+ return ;
416+ }
417+
418+ setStatus ( window . translations [ currentLanguage ] . updatingTypes || 'Aktualisiere Model-Types...' ) ;
419+
420+ const result = await window . electronAPI . updateModelTypes ( {
421+ dbPath : dbPath ,
422+ modelIds : selectedModelIds ,
423+ newType : newType
424+ } ) ;
425+
426+ if ( result . success ) {
427+ setStatus ( window . translations [ currentLanguage ] . typesUpdated + ` (${ result . updatedCount } von ${ selectedModelIds . length } Models aktualisiert)` ) ;
428+ // Models neu laden um aktualisierte Types anzuzeigen
429+ loadModelsButton . click ( ) ;
430+ } else {
431+ setStatus ( result . message , true ) ;
432+ }
433+
434+ } catch ( error ) {
435+ setStatus ( `Fehler beim Aktualisieren der Model-Types: ${ error . message } ` , true ) ;
436+ }
437+ } ) ;
438+
374439// Hilfsfunktion zum Anzeigen der Models
375440function displayModels ( ) {
376441 if ( ! modelsData || modelsData . length === 0 ) {
@@ -400,9 +465,17 @@ function displayModels() {
400465
401466 const modelInfo = document . createElement ( 'div' ) ;
402467 modelInfo . className = 'model-info' ;
468+
469+ // Extrahiere config-Type falls vorhanden
470+ let configType = 'Unbekannt' ;
471+ if ( model . config && model . config . type ) {
472+ configType = model . config . type ;
473+ }
474+
403475 modelInfo . innerHTML = `
404476 <strong>${ model . name || 'Unbenannt' } </strong><br>
405- <span>Typ: ${ model . type || 'Unbekannt' } </span><br>
477+ <span>DB-Typ: ${ model . type || 'Unbekannt' } </span><br>
478+ <span>Config-Typ: ${ configType } </span><br>
406479 <span>Pfad: ${ model . path || 'Kein Pfad' } </span>
407480 ` ;
408481
@@ -418,6 +491,7 @@ function updateSyncButtonState() {
418491 syncButton . disabled = ! dbPath || ! outputDir ;
419492 syncThumbnailsButton . disabled = ! dbPath || ! outputDir ;
420493 loadModelsButton . disabled = ! dbPath ;
494+ updateTypesButton . disabled = ! dbPath ;
421495}
422496
423497// Hilfsfunktion zum Anzeigen der Synchronisierungsergebnisse
0 commit comments