cloud poller id

This commit is contained in:
Graham McIntire 2026-01-25 08:52:35 -06:00
parent 1d638c0c83
commit 66fd6fa3b6
No known key found for this signature in database

View file

@ -61,10 +61,16 @@ defmodule ToweropsWeb.AgentLive.Index do
@impl true
def handle_event("create_agent", params, socket) do
require Logger
Logger.info("Agent creation params: #{inspect(params)}")
{name, is_cloud_poller} = parse_agent_params(params)
Logger.info("Parsed - name: #{name}, is_cloud_poller: #{is_cloud_poller}")
with :ok <- validate_cloud_poller_permission(socket.assigns.current_scope.user, is_cloud_poller),
{:ok, agent_token, token} <- create_agent(socket.assigns.current_organization, name, is_cloud_poller) do
Logger.info("Created agent_token - id: #{agent_token.id}, is_cloud_poller: #{agent_token.is_cloud_poller}")
handle_agent_creation_success(socket, agent_token, token, is_cloud_poller)
else
{:error, :unauthorized} ->
@ -194,6 +200,9 @@ defmodule ToweropsWeb.AgentLive.Index do
%{"agent_form" => %{"name" => n}} ->
{n, false}
%{"name" => n, "is_cloud_poller" => cp} ->
{n, cp in ["true", "on", true]}
%{"name" => n} ->
{n, false}
end