@@ -130,7 +130,7 @@ class Topology extends Window {
130130 this . content . onmouseup = event => this . Topology_onmouseup ( event ) ;
131131
132132 this . startButton . onclick = ( ) => this . StartDialog ( ) ;
133- this . syncButton . onclick = ( ) => this . UpdateDeviceUplink ( ) ;
133+ this . syncButton . onclick = ( ) => this . UpdateDeviceUplinkDialog ( ) ;
134134 this . findButton . onclick = ( ) => this . FindMode ( ) ;
135135 this . vlanButton . onclick = ( ) => this . VlanMode ( ) ;
136136 this . trafficButton . onclick = ( ) => this . TrafficMode ( ) ;
@@ -2698,7 +2698,7 @@ class Topology extends Window {
26982698 updateDbButton . style . backgroundImage = "url(mono/upload.svg)" ;
26992699 optionsBox . appendChild ( updateDbButton ) ;
27002700
2701- updateDbButton . onclick = ( ) => this . UpdateDeviceUplink ( file ) ;
2701+ updateDbButton . onclick = ( ) => this . UpdateDeviceUplinkDialog ( file ) ;
27022702 }
27032703
27042704 const overwriteProtocol = { } ;
@@ -2900,12 +2900,12 @@ class Topology extends Window {
29002900 }
29012901 }
29022902
2903- UpdateDeviceUplink ( target = "*" ) {
2903+ UpdateDeviceUplinkDialog ( target = "*" ) {
29042904 const dialog = this . DialogBox ( "calc(100% - 40px)" ) ;
29052905 if ( dialog === null ) return ;
29062906
29072907 const { okButton, innerBox} = dialog ;
2908- okButton . value = "Sync database uplinks" ;
2908+ okButton . value = "Save uplinks to Devices " ;
29092909
29102910 innerBox . parentElement . style . maxWidth = "720px" ;
29112911
@@ -2914,7 +2914,7 @@ class Topology extends Window {
29142914 innerBox . style . margin = "20px 20px 8px 20px" ;
29152915
29162916 const list = [ ] ;
2917-
2917+
29182918 for ( const file in this . devices ) {
29192919 if ( target !== "*" && file !== target ) continue ;
29202920
@@ -2923,6 +2923,8 @@ class Topology extends Window {
29232923 if ( device . isUnmanaged ) continue ;
29242924 if ( ! device . lldp || device . lldp . localPortName === 0 ) continue ;
29252925
2926+ const type = device . initial . type . toLowerCase ( ) ;
2927+
29262928 const switchBox = document . createElement ( "div" ) ;
29272929 switchBox . style . border = "2px solid var(--clr-control)" ;
29282930 switchBox . style . borderRadius = "4px" ;
@@ -2932,7 +2934,11 @@ class Topology extends Window {
29322934 titleBox . textContent = device . initial . hostname ;
29332935 titleBox . style . fontWeight = "bold" ;
29342936 titleBox . style . backgroundColor = "var(--clr-control)" ;
2935- titleBox . style . padding = "4px" ;
2937+ titleBox . style . padding = "4px 4px 4px 32px" ;
2938+ titleBox . style . backgroundImage = `url(${ type in LOADER . deviceIcons ? LOADER . deviceIcons [ type ] : "mono/gear.svg" } )` ;
2939+ titleBox . style . backgroundSize = "24px 24px" ;
2940+ titleBox . style . backgroundPosition = "2px 50%" ;
2941+ titleBox . style . backgroundRepeat = "no-repeat" ;
29362942
29372943 const contentBox = document . createElement ( "div" ) ;
29382944
@@ -2978,6 +2984,7 @@ class Topology extends Window {
29782984 deviceLabel . style . overflow = "hidden" ;
29792985 deviceLabel . style . textOverflow = "ellipsis" ;
29802986 deviceLabel . style . whiteSpace = "nowrap" ;
2987+ deviceLabel . style . userSelect = "text" ;
29812988 newItem . appendChild ( deviceLabel ) ;
29822989
29832990 if ( "hostname" in dbEntry && dbEntry . hostname . v . length > 0 ) {
@@ -2999,11 +3006,14 @@ class Topology extends Window {
29993006 }
30003007
30013008 list . push ( {
3009+ uplink : file ,
30023010 toggle : toggle ,
30033011 file : entry [ i ] ,
30043012 port : portName
30053013 } ) ;
30063014
3015+ deviceLabel . onclick = event => event . stopPropagation ( ) ;
3016+
30073017 newItem . onclick = ( ) => {
30083018 toggle . checkbox . checked = ! toggle . checkbox . checked ;
30093019 } ;
@@ -3020,18 +3030,24 @@ class Topology extends Window {
30203030 for ( let i = 0 ; i < list . length ; i ++ ) {
30213031 if ( ! list [ i ] . toggle . checkbox . checked ) continue ;
30223032
3023- mods [ list [ i ] . file ] = {
3024- uplink : JSON . stringify ( {
3025- device : file ,
3026- port : list [ i ] . port
3027- } )
3028- } ;
3033+ if ( ! mods [ list [ i ] . file ] ) {
3034+ mods [ list [ i ] . file ] = [ ] ;
3035+ }
3036+
3037+ mods [ list [ i ] . file ] . push ( {
3038+ device : list [ i ] . uplink ,
3039+ port : list [ i ] . port
3040+ } ) ;
3041+ }
3042+
3043+ for ( const file in mods ) {
3044+ mods [ file ] = { "uplink" : JSON . stringify ( mods [ file ] ) } ;
30293045 }
30303046
30313047 try {
30323048 const response = await fetch ( "db/device/grid" , {
30333049 method : "POST" ,
3034- body : JSON . stringify ( mods )
3050+ body : JSON . stringify ( mods )
30353051 } ) ;
30363052
30373053 if ( response . status !== 200 ) LOADER . HttpErrorHandler ( response . status ) ;
0 commit comments