<% content_for :body_class, "admin-body" %>

<%= t("admin.stream_nodes.title") %>

<%= t("admin.stream_nodes.providers", cloud: @cloud_provider, dns: @dns_provider) %>

<% m = @autoscale_metrics %>
<%= t("admin.stream_nodes.kpi.autoscaler") %>
<%= m[:kill_switch] ? t("admin.stream_nodes.kpi.kill_switch") : (m[:enabled] ? "ON" : "OFF") %>
<%= t("admin.stream_nodes.kpi.kind", kind: m[:kind]) %>
<%= t("admin.stream_nodes.kpi.free_slots") %>
<%= m[:free_slots] %>
<%= t("admin.stream_nodes.kpi.soft_slots", soft: m[:soft_free_slots]) %>
<%= t("admin.stream_nodes.kpi.spare") %>
<%= m[:spare_ready] %>/<%= m[:warm_spare_min] %>
<%= t("admin.stream_nodes.kpi.warm_spare") %>
<%= t("admin.stream_nodes.kpi.overflow") %>
<%= m[:overflow_nodes] %>/<%= m[:max_overflow_nodes] %>
<%= t("admin.stream_nodes.kpi.overflow_nodes") %>
<%= t("admin.stream_nodes.kpi.budget") %>
€<%= m[:estimated_monthly_eur] %>
<%= t("admin.stream_nodes.kpi.budget_of", budget: m[:monthly_budget_eur], ok: (m[:within_budget] ? "OK" : "OVER")) %>

<%= t("admin.stream_nodes.actions_title") %>

<%= button_to t("admin.stream_nodes.provision_lab"), admin_stream_nodes_path, method: :post, params: { kind: "lab" }, class: "admin-btn admin-btn--secondary" %> <% if @hetzner_configured %> <%= button_to t("admin.stream_nodes.provision_cloud"), admin_stream_nodes_path, method: :post, params: { kind: "cloud" }, class: "admin-btn admin-btn--primary", form: { data: { confirm: t("admin.stream_nodes.provision_cloud_confirm") } } %> <% else %> <%= t("admin.stream_nodes.hetzner_token_missing") %> <% end %> <% if m[:kill_switch] %> <%= button_to t("admin.stream_nodes.clear_kill_switch"), clear_kill_switch_admin_stream_nodes_path, method: :delete, class: "admin-btn admin-btn--secondary" %> <% else %> <%= button_to t("admin.stream_nodes.engage_kill_switch"), kill_switch_admin_stream_nodes_path, method: :post, class: "admin-btn admin-btn--danger", form: { data: { confirm: t("admin.stream_nodes.kill_switch_confirm") } } %> <% end %>

<%= t("admin.stream_nodes.table_title") %>

<% if @nodes.any? %>
<% @nodes.each do |node| %> <% badge = case node.status when "ready" then "badge--ready" when "provisioning", "draining" then "badge--connecting" when "error", "offline" then "badge--paused" else "badge--paused" end %> <% end %>
<%= t("admin.stream_nodes.col.slug") %> <%= t("admin.stream_nodes.col.role") %> <%= t("admin.stream_nodes.col.status") %> <%= t("admin.stream_nodes.col.slots") %> <%= t("admin.stream_nodes.col.hostname") %> <%= t("admin.stream_nodes.col.provider") %>
<%= node.slug %> <%= node.role %> <%= node.status %> <%= node.active_publishers %> / <%= node.max_publishers %>
<%= t("admin.stream_nodes.free_slots", count: node.free_slots) %>
<%= node.hostname %> <%= node.provider %> <% if node.provider_instance_id.present? %>
<%= node.provider_instance_id %>
<% end %>
<% if node.slug != "home" %> <% if node.status == "ready" %> <%= button_to t("admin.stream_nodes.drain"), drain_admin_stream_node_path(node), method: :post, class: "admin-btn admin-btn--sm admin-btn--secondary" %> <% end %> <%= button_to t("admin.stream_nodes.destroy"), admin_stream_node_path(node), method: :delete, class: "admin-btn admin-btn--sm admin-btn--danger", form: { data: { confirm: t("admin.stream_nodes.destroy_confirm", slug: node.slug) } } %> <% else %> <% end %>
<% else %>

<%= t("admin.stream_nodes.empty") %>

<% end %>
<% if @lab_hosts.present? %>

<%= t("admin.stream_nodes.hosts_title") %>

<%= @lab_hosts %>
<% end %>