77 "github.com/NodeboxHQ/node-dashboard/services/dusk"
88 "github.com/NodeboxHQ/node-dashboard/services/linea"
99 "github.com/NodeboxHQ/node-dashboard/services/nulink"
10+ "github.com/NodeboxHQ/node-dashboard/services/xally"
1011 "github.com/NodeboxHQ/node-dashboard/utils"
1112 "github.com/gofiber/fiber/v2"
1213 "github.com/mackerelio/go-osstat/cpu"
@@ -55,6 +56,8 @@ func GetLogo(config *config.Config) fiber.Handler {
5556 return c .SendString (fmt .Sprintf (`<img src="/assets/img/logo/nulink-logo.png?nodeip=%s" alt="logo-expanded" class="w-52 h-auto object-contain mx-auto block" />` , config .IPv4 ))
5657 } else if config .Node == "Babylon" {
5758 return c .SendString (fmt .Sprintf (`<img src="/assets/img/logo/babylon-logo.png?nodeip=%s" alt="logo-expanded" class="w-52 h-auto object-contain mx-auto block" />` , config .IPv4 ))
59+ } else if config .Node == "Xally" {
60+ return c .SendString (fmt .Sprintf (`<img src="/assets/img/logo/xally-logo.png?nodeip=%s" alt="logo-expanded" class="w-52 h-auto object-contain mx-auto block" />` , config .IPv4 ))
5861 } else {
5962 return c .SendString ("" )
6063 }
@@ -64,7 +67,7 @@ func GetLogo(config *config.Config) fiber.Handler {
6467func GetCPUUsage (ipv4 string ) fiber.Handler {
6568 return func (c * fiber.Ctx ) error {
6669 cpuUsageTemplate := `
67- <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/cpu?nodeip=%s" hx-trigger="load" hx-swap="outerHTML transition:true ">
70+ <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/cpu?nodeip=%s" hx-trigger="load" hx-swap="outerHTML">
6871 <h3 class="mb-2.5 text-center text-cardTitleColor text-lg font-semibold">CPU</h3>
6972 <div class="flex flex-col">
7073 <div class="flex content-between items-center gap-1.5 justify-around flex-col">
@@ -104,7 +107,7 @@ func GetCPUUsage(ipv4 string) fiber.Handler {
104107func GetRAMUsage (ipv4 string ) fiber.Handler {
105108 return func (c * fiber.Ctx ) error {
106109 ramUsageTemplate := `
107- <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/ram?nodeip=%s" hx-trigger="every 1s" hx-swap="outerHTML transition:true ">
110+ <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/ram?nodeip=%s" hx-trigger="every 1s" hx-swap="outerHTML">
108111 <h3 class="mb-2.5 text-center text-cardTitleColor text-lg font-semibold">RAM</h3>
109112 <div class="flex flex-col">
110113 <div class="flex content-between items-center gap-1.5 justify-around flex-col">
@@ -136,7 +139,7 @@ func GetRAMUsage(ipv4 string) fiber.Handler {
136139func GetDiskUsage (ipv4 string ) fiber.Handler {
137140 return func (c * fiber.Ctx ) error {
138141 diskUsageTemplate := `
139- <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/disk?nodeip=%s" hx-trigger="every 1s" hx-swap="outerHTML transition:true ">
142+ <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/disk?nodeip=%s" hx-trigger="every 1s" hx-swap="outerHTML">
140143 <h3 class="mb-2.5 text-center text-cardTitleColor text-lg font-semibold">Disk Usage</h3>
141144 <div class="flex flex-col">
142145 <div class="flex content-between items-center gap-1.5 justify-around flex-col">
@@ -189,7 +192,7 @@ func GetDiskUsage(ipv4 string) fiber.Handler {
189192func GetSystemUptime (ipv4 string ) fiber.Handler {
190193 return func (c * fiber.Ctx ) error {
191194 uptimeTemplate := `
192- <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/uptime?nodeip=%s" hx-trigger="every 1s" hx-swap="outerHTML transition:true ">
195+ <div class="items-center py-2.5 px-5 border backdrop-blur-md border-cardBackgroundColor rounded-[20px] bg-cardBackgroundColor w-full shadow-md" hx-get="/data/uptime?nodeip=%s" hx-trigger="every 1s" hx-swap="outerHTML">
193196 <h3 class="mb-2.5 text-center text-cardTitleColor text-lg font-semibold">Uptime</h3>
194197 <div class="flex flex-col">
195198 <div class="flex content-between items-center gap-1.5 justify-around flex-col">
@@ -240,7 +243,7 @@ func GetActivity(config *config.Config) fiber.Handler {
240243 adjective = "Online"
241244 }
242245
243- tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Private IPv4</b> - %s <br> <b> Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s <br>" , config .Node , config .Owner , config . PrivateIPv4 , config .IPv4 , config .IPv6 )
246+ tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s <br>" , config .Node , config .Owner , config .IPv4 , config .IPv6 )
244247
245248 needBr := ""
246249
@@ -280,7 +283,7 @@ func GetActivity(config *config.Config) fiber.Handler {
280283 adjective = "Online"
281284 }
282285
283- tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Version</b> - %s <br> <b>Owner</b> - %s<br> <b>Private IPv4</b> - %s <br> <b> Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s <br>" , config .Node , status .Version , config .Owner , config . PrivateIPv4 , config .IPv4 , config .IPv6 )
286+ tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Version</b> - %s <br> <b>Owner</b> - %s<br> <b>Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s <br>" , config .Node , status .Version , config .Owner , config .IPv4 , config .IPv6 )
284287
285288 needBr := ""
286289
@@ -315,7 +318,7 @@ func GetActivity(config *config.Config) fiber.Handler {
315318 adjective = "Offline"
316319 }
317320
318- tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Private IPv4</b> - %s <br> <b> Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s" , config .Node , config .Owner , config . PrivateIPv4 , config .IPv4 , config .IPv6 )
321+ tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s" , config .Node , config .Owner , config .IPv4 , config .IPv6 )
319322
320323 tippyContent = tippyContent + fmt .Sprintf ("<br> <b>Dashboard Version</b> - %s" , config .NodeboxDashboardVersion )
321324 activityTemplate = strings .Replace (activityTemplate , "ALPINE_TOOLTIP" , fmt .Sprintf (`tooltip-data="%s"` , tippyContent ), - 1 )
@@ -344,7 +347,7 @@ func GetActivity(config *config.Config) fiber.Handler {
344347 adjective = "Online"
345348 }
346349
347- tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Private IPv4</b> - %s <br> <b> Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s <br>" , config .Node , config .Owner , config . PrivateIPv4 , config .IPv4 , config .IPv6 )
350+ tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s <br>" , config .Node , config .Owner , config .IPv4 , config .IPv6 )
348351
349352 needBr := ""
350353
@@ -356,6 +359,70 @@ func GetActivity(config *config.Config) fiber.Handler {
356359 tippyContent = tippyContent + fmt .Sprintf ("%s <b>Dashboard Version</b> - %s" , needBr , config .NodeboxDashboardVersion )
357360 activityTemplate = strings .Replace (activityTemplate , "ALPINE_TOOLTIP" , fmt .Sprintf (`tooltip-data="%s"` , tippyContent ), - 1 )
358361
362+ return c .SendString (fmt .Sprintf (activityTemplate , color , adjective ))
363+ } else if config .Node == "Xally" {
364+ activityTemplate := `
365+ <div class="w-64 h-7 mt-5 rounded-full overflow-hidden relative m-0" hx-get="/data/activity?nodeip=NODE_IP" hx-trigger="every 1s" hx-swap="outerHTML" id="activity-bar" ALPINE_TOOLTIP>
366+ <div class="absolute top-0 left-0 w-full z-0 h-full bg-progressBarBackgroundColor rounded-full"></div>
367+ <div class="absolute top-0 left-0 h-full rounded-[10px] transition-[width] w-full z-10 %s"></div>
368+ <div class="items-center text-sm font-bold text-textColor absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-20"> Node %s </div>
369+ </div>
370+ `
371+
372+ status , _ := xally .FetchNodeData ()
373+
374+ color := ""
375+ adjective := ""
376+ totalRunTime := 0.0
377+ accumulatedGXally := 0.0
378+ lastUpdate := ""
379+
380+ var keyIDs []string
381+ var nodeIDs string
382+
383+ activityTemplate = strings .Replace (activityTemplate , "NODE_IP" , config .IPv4 , - 1 )
384+
385+ if len (status ) == 0 {
386+ color = "bg-red-500"
387+ adjective = "Offline"
388+ } else {
389+ color = "bg-green-500"
390+ adjective = "Online"
391+
392+ for _ , node := range status {
393+ totalRunTime += node .RunningTime
394+ accumulatedGXally += node .Point
395+ keyIDs = append (keyIDs , node .KeyID )
396+
397+ lastCheckTS := node .LastCheckTS
398+ lastCheckTime := time .Unix (lastCheckTS , 0 )
399+ duration := time .Since (lastCheckTime ).Round (time .Second )
400+ minutes := duration / time .Minute
401+ seconds := (duration % time .Minute ) / time .Second
402+
403+ if minutes > 0 {
404+ lastUpdate = fmt .Sprintf ("%dm %ds ago" , minutes , seconds )
405+ } else {
406+ lastUpdate = fmt .Sprintf ("%ds ago" , seconds )
407+ }
408+ }
409+
410+ nodeIDs = strings .Join (keyIDs , ", " )
411+ }
412+
413+ tippyContent := fmt .Sprintf ("<b>Node</b> - %s <br> <b>Owner</b> - %s<br> <b>Public IPv4</b> - %s <br> <b>Public IPv6</b> - %s" , config .Node , config .Owner , config .IPv4 , config .IPv6 )
414+
415+ if len (status ) == 0 {
416+ color = "bg-red-500"
417+ adjective = "Offline"
418+ tippyContent += fmt .Sprintf ("<br> <b>Dashboard Version</b> - %s" , config .NodeboxDashboardVersion )
419+ } else {
420+ color = "bg-green-500"
421+ adjective = "Online"
422+ tippyContent += fmt .Sprintf ("<br> <b>Total Nodes</b> - %d (%s) <br> <b>Total Running Time</b> - %.2f <br> <b>Total gXally</b> - %.2f <br> <b>Last Data Update</b> - %s <br> <b>Dashboard Version</b> - %s" , len (status ), nodeIDs , totalRunTime , accumulatedGXally , lastUpdate , config .NodeboxDashboardVersion )
423+ }
424+
425+ activityTemplate = strings .Replace (activityTemplate , "ALPINE_TOOLTIP" , fmt .Sprintf (`tooltip-data="%s"` , tippyContent ), - 1 )
359426 return c .SendString (fmt .Sprintf (activityTemplate , color , adjective ))
360427 } else {
361428 return c .SendString ("" )
0 commit comments