33< head >
44 < meta charset ="UTF-8 ">
55 < title > Node Manager</ title >
6- < link rel ="icon " href ="favicon.ico " type ="image/x-icon ">
76 < link rel ="stylesheet " href ="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css " />
87 < script src ="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js "> </ script >
98
@@ -369,7 +368,7 @@ <h2>🔗 Collaboration Settings</h2>
369368 setTimeout ( ( ) => {
370369 closeModal ( ) ;
371370 location . reload ( ) ; // Reload to refresh UI with new data
372- } , 5000 ) ;
371+ } , 1000 ) ;
373372 } else {
374373 showMessage ( result . error || 'Failed to connect' , 'error' ) ;
375374 }
@@ -565,7 +564,7 @@ <h2>🔗 Collaboration Settings</h2>
565564 } catch ( e ) {
566565 // Silent fail on polling
567566 }
568- } , 300000 ) ; // Poll every 5 minutes
567+ } , 15000 ) ; // Poll every 15 seconds
569568
570569 if ( document . readyState === 'loading' ) {
571570 document . addEventListener ( 'DOMContentLoaded' , initialize ) ;
@@ -955,7 +954,6 @@ <h2>Groups</h2>
955954 ` ;
956955 tbody . appendChild ( row ) ;
957956 } ) ;
958- localStorage . setItem ( 'nodes' , JSON . stringify ( nodes ) ) ;
959957 updateMapMarkers ( ) ;
960958 }
961959
@@ -974,7 +972,6 @@ <h2>Groups</h2>
974972 ` ;
975973 tbody . appendChild ( row ) ;
976974 } ) ;
977- localStorage . setItem ( 'groups' , JSON . stringify ( groups ) ) ;
978975 }
979976
980977 // === Map Markers ===
@@ -1008,6 +1005,12 @@ <h2>Groups</h2>
10081005 }
10091006 }
10101007
1008+ // === Save Data (only call this when user makes actual changes) ===
1009+ function saveData ( ) {
1010+ localStorage . setItem ( 'nodes' , JSON . stringify ( nodes ) ) ;
1011+ localStorage . setItem ( 'groups' , JSON . stringify ( groups ) ) ;
1012+ }
1013+
10111014 // === Node CRUD ===
10121015 function addNode ( ) {
10131016 clearMessages ( ) ;
@@ -1036,6 +1039,7 @@ <h2>Groups</h2>
10361039 }
10371040
10381041 clearForm ( ) ;
1042+ saveData ( ) ;
10391043 renderNodeTable ( ) ;
10401044 renderGroupTable ( ) ;
10411045 }
@@ -1071,6 +1075,7 @@ <h2>Groups</h2>
10711075 nodes . splice ( index , 1 ) ;
10721076 groups = groups . filter ( g => g . name !== name ) ;
10731077 groups . forEach ( g => g . nodes = g . nodes . filter ( n => n !== name ) ) ;
1078+ saveData ( ) ;
10741079 renderNodeTable ( ) ;
10751080 renderGroupTable ( ) ;
10761081 showSuccess ( 'Node deleted.' ) ;
@@ -1080,6 +1085,7 @@ <h2>Groups</h2>
10801085 function updateIncluded ( index , checked ) {
10811086 nodes [ index ] . included = checked ;
10821087 if ( nodes [ index ] . primary ) nodes [ index ] . included = true ;
1088+ saveData ( ) ;
10831089 renderNodeTable ( ) ;
10841090 }
10851091
@@ -1088,6 +1094,7 @@ <h2>Groups</h2>
10881094 n . primary = i === index ;
10891095 if ( i === index ) n . included = true ;
10901096 } ) ;
1097+ saveData ( ) ;
10911098 renderNodeTable ( ) ;
10921099 }
10931100
@@ -1126,12 +1133,14 @@ <h2>Groups</h2>
11261133 showSuccess ( `Group "${ primary . name } " created!` ) ;
11271134 }
11281135
1136+ saveData ( ) ;
11291137 renderGroupTable ( ) ;
11301138 }
11311139
11321140 function deleteGroup ( index ) {
11331141 if ( confirm ( `Delete group "${ groups [ index ] . name } "?` ) ) {
11341142 groups . splice ( index , 1 ) ;
1143+ saveData ( ) ;
11351144 renderGroupTable ( ) ;
11361145 showSuccess ( 'Group deleted.' ) ;
11371146 }
@@ -1142,6 +1151,7 @@ <h2>Groups</h2>
11421151 if ( g . name === oldName ) g . name = newName ;
11431152 g . nodes = g . nodes . map ( n => n === oldName ? newName : n ) ;
11441153 } ) ;
1154+ // Note: saveData() is called by the parent function (addNode) that calls this
11451155 renderGroupTable ( ) ;
11461156 }
11471157
@@ -1216,6 +1226,7 @@ <h2>Groups</h2>
12161226 const replace = confirm ( 'Replace existing nodes? (Cancel = Append)' ) ;
12171227 nodes = replace ? newNodes : [ ...nodes , ...newNodes ] ;
12181228 if ( replace ) groups = [ ] ;
1229+ saveData ( ) ;
12191230 renderNodeTable ( ) ; renderGroupTable ( ) ;
12201231 showSuccess ( `${ newNodes . length } nodes ${ replace ? 'replaced' : 'appended' } .` ) ;
12211232 } ;
0 commit comments