<.icon name="hero-server" class="mx-auto h-12 w-12 text-gray-400 dark:text-gray-500" />
{t("No agents")}
{t("Get started by creating your first remote agent.")}
<.button phx-click={JS.show(to: "#new-agent-form")} variant="primary">
<.icon name="hero-plus" class="h-5 w-5" /> New Agent
<% else %>
<.table
id="agents-table"
rows={@streams.agent_tokens}
row_link={fn {_id, agent} -> ~p"/agents/#{agent.id}" end}
>
<:col :let={{_id, agent}} label={t("Name")}>
{agent.name}
<%= if agent.is_cloud_poller do %>
<.icon name="hero-cloud" class="h-3 w-3" /> Cloud
<% end %>
<%= if agent.allow_remote_debug do %>
<.icon name="hero-bug-ant" class="h-3 w-3" /> Debug
<% end %>
<:col :let={{_id, agent}} label={t("Status")}>
<% {status, label} = agent_status(agent) %>
{label}
<:col :let={{_id, agent}} label={t("Device")}>
<% counts = Map.get(@device_counts, agent.id, %{direct: 0, total: 0}) %>
{counts.total} total
{counts.direct} direct
<%= if counts.total > counts.direct do %>
· {counts.total - counts.direct} inherited
<% end %>
<:col :let={{_id, agent}} label={t("Last Seen")}>
<.timestamp datetime={agent.last_seen_at} timezone={@timezone} now={@now} />
<%= if agent.last_seen_at do %>
<.timestamp datetime={agent.last_seen_at} timezone={@timezone} format="absolute" />
<% end %>
<%= if agent.last_ip do %>
{agent.last_ip}
<% end %>
<:col :let={{_id, agent}} label={t("Version")}>
<%= if agent.metadata["version"] do %>
{format_agent_version(agent.metadata["version"])}
<% end %>
<:col :let={{_id, agent}} label={t("Created")}>
{ToweropsWeb.TimeHelpers.format_date(agent.inserted_at, @timezone)}
<:action :let={{_id, agent}}>
<%= if agent.enabled do %>
<.button
type="button"
phx-click="show_setup"
phx-value-id={agent.id}
variant="secondary"
>
{t("View Setup")}
<.button
type="button"
phx-click="delete_agent"
phx-value-id={agent.id}
data-confirm={
t(
"Are you sure you want to delete this agent? All device assignments will be removed, and devices will fall back to site/organization defaults or cloud polling."
)
}
variant="danger"
>
{t("Delete")}
<% else %>
Disabled
<% end %>
<% end %>
<%!-- Cloud Pollers Section (Superadmin Only) --%>
<%= if @is_superuser && @has_cloud_pollers do %>
{t("Cloud Pollers")}
{t(
"Application-wide agents that can poll devices for any organization. Only visible and manageable by superadmins."
)}
<.table
id="cloud-pollers-table"
rows={@streams.cloud_pollers}
row_link={fn {_id, agent} -> ~p"/agents/#{agent.id}" end}
>
<:col :let={{_id, agent}} label={t("Name")}>
{agent.name}
<%= if agent.id == @global_default_cloud_poller_id do %>
<.icon name="hero-check-circle" class="h-3 w-3" /> Default
<% end %>
<%= if agent.allow_remote_debug do %>
<.icon name="hero-bug-ant" class="h-3 w-3" /> Debug
<% end %>
<:col :let={{_id, agent}} label={t("Status")}>
<% {status, label} = agent_status(agent) %>
{label}
<:col :let={{_id, agent}} label={t("Device")}>
<% counts = Map.get(@cloud_poller_counts, agent.id, %{direct: 0, total: 0}) %>
{counts.total} total
{counts.direct} direct
<%= if counts.total > counts.direct do %>
· {counts.total - counts.direct} inherited
<% end %>
<:col :let={{_id, agent}} label={t("Last Seen")}>
<.timestamp datetime={agent.last_seen_at} timezone={@timezone} now={@now} />
<%= if agent.last_seen_at do %>
<.timestamp datetime={agent.last_seen_at} timezone={@timezone} format="absolute" />
<% end %>
<%= if agent.last_ip do %>
{agent.last_ip}
<% end %>
<:col :let={{_id, agent}} label={t("Version")}>
<%= if agent.metadata["version"] do %>
{format_agent_version(agent.metadata["version"])}
<% end %>
<:col :let={{_id, agent}} label={t("Created")}>
{ToweropsWeb.TimeHelpers.format_date(agent.inserted_at, @timezone)}
<:action :let={{_id, agent}}>
<%= if agent.enabled do %>
<.button
type="button"
phx-click="show_setup"
phx-value-id={agent.id}
variant="secondary"
>
{t("View Setup")}
<.button
type="button"
phx-click="delete_agent"
phx-value-id={agent.id}
data-confirm={
t(
"Are you sure you want to delete this cloud poller? This will affect all organizations using it."
)
}
variant="danger"
>
{t("Delete")}
<% else %>
Disabled
<% end %>
<% end %>
<%!-- Global Default Cloud Poller (Superadmin Only) --%>
<%= if @is_superuser do %>