@@ -4,6 +4,8 @@ document.addEventListener('DOMContentLoaded', async () => {
44 const response = await fetch ( '/settings/api/da-config' ) ;
55 const config = await response . json ( ) ;
66
7+ console . log ( 'Loaded config:' , config ) ;
8+
79 if ( config . da_server ) document . getElementById ( 'da_server' ) . value = config . da_server ;
810 if ( config . da_username ) document . getElementById ( 'da_username' ) . value = config . da_username ;
911 if ( config . da_domain ) document . getElementById ( 'da_domain' ) . value = config . da_domain ;
@@ -21,12 +23,14 @@ document.getElementById('daConfigForm').addEventListener('submit', async (e) =>
2123 e . preventDefault ( ) ;
2224
2325 const formData = {
24- da_server : document . getElementById ( 'da_server' ) . value ,
25- da_username : document . getElementById ( 'da_username' ) . value ,
26+ da_server : document . getElementById ( 'da_server' ) . value . trim ( ) ,
27+ da_username : document . getElementById ( 'da_username' ) . value . trim ( ) ,
2628 da_password : document . getElementById ( 'da_password' ) . value ,
27- da_domain : document . getElementById ( 'da_domain' ) . value
29+ da_domain : document . getElementById ( 'da_domain' ) . value . trim ( )
2830 } ;
2931
32+ console . log ( 'Submitting settings:' , { ...formData , da_password : '***' } ) ;
33+
3034 try {
3135 const response = await fetch ( '/settings/api/da-config' , {
3236 method : 'POST' ,
@@ -37,6 +41,7 @@ document.getElementById('daConfigForm').addEventListener('submit', async (e) =>
3741 } ) ;
3842
3943 const result = await response . json ( ) ;
44+ console . log ( 'Save response:' , result ) ;
4045
4146 if ( response . ok ) {
4247 alert ( 'Settings saved successfully!' ) ;
@@ -49,19 +54,20 @@ document.getElementById('daConfigForm').addEventListener('submit', async (e) =>
4954 window . location . href = '/dashboard' ;
5055 } , 1000 ) ;
5156 } else {
57+ console . error ( 'Save failed:' , result ) ;
5258 alert ( result . error || 'Failed to save settings' ) ;
5359 }
5460 } catch ( error ) {
5561 console . error ( 'Error saving settings:' , error ) ;
56- alert ( 'Error saving settings' ) ;
62+ alert ( 'Error saving settings: ' + error . message ) ;
5763 }
5864} ) ;
5965
6066// Test connection function
6167async function testConnection ( ) {
6268 const formData = {
63- da_server : document . getElementById ( 'da_server' ) . value ,
64- da_username : document . getElementById ( 'da_username' ) . value ,
69+ da_server : document . getElementById ( 'da_server' ) . value . trim ( ) ,
70+ da_username : document . getElementById ( 'da_username' ) . value . trim ( ) ,
6571 da_password : document . getElementById ( 'da_password' ) . value
6672 } ;
6773
@@ -74,6 +80,8 @@ async function testConnection() {
7480 return ;
7581 }
7682
83+ console . log ( 'Testing connection to:' , formData . da_server ) ;
84+
7785 try {
7886 const response = await fetch ( '/settings/api/test-connection' , {
7987 method : 'POST' ,
@@ -84,6 +92,7 @@ async function testConnection() {
8492 } ) ;
8593
8694 const result = await response . json ( ) ;
95+ console . log ( 'Test response:' , result ) ;
8796
8897 if ( response . ok ) {
8998 alert ( '✓ ' + result . message ) ;
@@ -92,6 +101,6 @@ async function testConnection() {
92101 }
93102 } catch ( error ) {
94103 console . error ( 'Error testing connection:' , error ) ;
95- alert ( '✗ Connection test failed' ) ;
104+ alert ( '✗ Connection test failed: ' + error . message ) ;
96105 }
97106}
0 commit comments