diff --git a/apps/dashboard/app/helpers/system_status_helper.rb b/apps/dashboard/app/helpers/system_status_helper.rb index b7610b7ec3..b1865a75b0 100644 --- a/apps/dashboard/app/helpers/system_status_helper.rb +++ b/apps/dashboard/app/helpers/system_status_helper.rb @@ -6,37 +6,24 @@ def title(cluster) "#{cluster.metadata.title.titleize} Cluster Status" end - def percent(value, total) - "#{(value.to_f / total * 100).round 2}%" - end - - def generic_status(active, total, name) - free = number_with_delimiter(total - active) - "#{name} Active: #{number_with_delimiter(active)}/#{number_with_delimiter(total)} (#{free} Free)" - end - - def node_status(cluster_info) - generic_status(cluster_info.active_nodes, cluster_info.total_nodes, 'Nodes') - end - - def node_pct(cluster_info) - percent(cluster_info.active_nodes, cluster_info.total_nodes) - end - - def processor_status(cluster_info) - generic_status(cluster_info.active_processors, cluster_info.total_processors, 'Processors') + def status_hash(name, active, total) + { + message: "#{name} Available: #{number_with_delimiter(total - active)}", + percent: percent(active, total) + } end - def processor_pct(cluster_info) - percent(cluster_info.active_processors, cluster_info.total_processors) + def components_status(job_adapter) + cluster_info = job_adapter.cluster_info + [ + status_hash('Nodes', cluster_info.active_nodes, cluster_info.total_nodes), + status_hash('Processors', cluster_info.active_processors, cluster_info.total_processors), + status_hash('GPUs', cluster_info.active_gpus, cluster_info.total_gpus) + ] end - def gpu_status(cluster_info) - generic_status(cluster_info.active_gpus, cluster_info.total_gpus, 'GPUs') - end - - def gpu_pct(cluster_info) - percent(cluster_info.active_gpus, cluster_info.total_gpus) + def percent(value, total) + "#{(value.to_f / total * 100).round 2}%" end def active_jobs(job_adapter) diff --git a/apps/dashboard/app/views/system_status/index.turbo_stream.erb b/apps/dashboard/app/views/system_status/index.turbo_stream.erb index f708d4785a..56b481a7dc 100644 --- a/apps/dashboard/app/views/system_status/index.turbo_stream.erb +++ b/apps/dashboard/app/views/system_status/index.turbo_stream.erb @@ -2,31 +2,39 @@