add gaiia to org settings integrations page
This commit is contained in:
parent
ee277a457e
commit
6b2de4a114
2 changed files with 50 additions and 18 deletions
|
|
@ -2,6 +2,7 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
|
|||
@moduledoc false
|
||||
use ToweropsWeb, :live_view
|
||||
|
||||
alias Towerops.Gaiia.Client, as: GaiiaClient
|
||||
alias Towerops.Integrations
|
||||
alias Towerops.Integrations.Integration
|
||||
alias Towerops.Preseem.Client, as: PreseemClient
|
||||
|
|
@ -12,6 +13,13 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
|
|||
name: "Preseem",
|
||||
description: "QoE monitoring and subscriber experience analytics for wireless ISPs.",
|
||||
icon: "hero-signal"
|
||||
},
|
||||
%{
|
||||
id: "gaiia",
|
||||
name: "Gaiia",
|
||||
description:
|
||||
"Billing and subscriber management. Enables outage impact analysis, inventory reconciliation, and subscriber-aware monitoring.",
|
||||
icon: "hero-user-group"
|
||||
}
|
||||
]
|
||||
|
||||
|
|
@ -112,11 +120,12 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
|
|||
@impl true
|
||||
def handle_event("test_connection", _params, socket) do
|
||||
api_key = extract_api_key(socket)
|
||||
provider = socket.assigns.configuring
|
||||
|
||||
if api_key == "" or is_nil(api_key) do
|
||||
{:noreply, assign(socket, :test_result, {:error, "Please enter an API key first"})}
|
||||
else
|
||||
result = PreseemClient.test_connection(api_key)
|
||||
result = test_provider_connection(provider, api_key)
|
||||
{:noreply, assign(socket, :test_result, format_connection_result(result))}
|
||||
end
|
||||
end
|
||||
|
|
@ -143,6 +152,10 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
|
|||
end
|
||||
end
|
||||
|
||||
defp test_provider_connection("preseem", api_key), do: PreseemClient.test_connection(api_key)
|
||||
defp test_provider_connection("gaiia", api_key), do: GaiiaClient.test_connection(api_key)
|
||||
defp test_provider_connection(_, _api_key), do: {:error, "Unknown provider"}
|
||||
|
||||
defp load_integrations(organization_id) do
|
||||
organization_id
|
||||
|> Integrations.list_integrations()
|
||||
|
|
@ -189,8 +202,7 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
|
|||
defp format_connection_result({:error, {:unexpected_status, status}}),
|
||||
do: {:error, "API returned unexpected status: #{status}"}
|
||||
|
||||
defp format_connection_result({:error, %{reason: :timeout}}),
|
||||
do: {:error, "Connection timeout - unable to reach Preseem API"}
|
||||
defp format_connection_result({:error, %{reason: :timeout}}), do: {:error, "Connection timeout - unable to reach API"}
|
||||
|
||||
defp format_connection_result({:error, %{reason: :econnrefused}}),
|
||||
do: {:error, "Connection refused - check API endpoint"}
|
||||
|
|
|
|||
|
|
@ -81,20 +81,40 @@
|
|||
</span>
|
||||
<% end %>
|
||||
|
||||
<.link
|
||||
navigate={~p"/orgs/#{@organization.slug}/settings/integrations/preseem/devices"}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
||||
>
|
||||
Manage Devices →
|
||||
</.link>
|
||||
<.link
|
||||
navigate={
|
||||
~p"/orgs/#{@organization.slug}/settings/integrations/preseem/insights"
|
||||
}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
||||
>
|
||||
Network Insights →
|
||||
</.link>
|
||||
<%= if provider.id == "preseem" do %>
|
||||
<.link
|
||||
navigate={
|
||||
~p"/orgs/#{@organization.slug}/settings/integrations/preseem/devices"
|
||||
}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
||||
>
|
||||
Manage Devices →
|
||||
</.link>
|
||||
<.link
|
||||
navigate={
|
||||
~p"/orgs/#{@organization.slug}/settings/integrations/preseem/insights"
|
||||
}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
||||
>
|
||||
Network Insights →
|
||||
</.link>
|
||||
<% end %>
|
||||
<%= if provider.id == "gaiia" do %>
|
||||
<.link
|
||||
navigate={~p"/orgs/#{@organization.slug}/settings/integrations/gaiia/mapping"}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
||||
>
|
||||
Entity Mapping →
|
||||
</.link>
|
||||
<.link
|
||||
navigate={
|
||||
~p"/orgs/#{@organization.slug}/settings/integrations/gaiia/reconciliation"
|
||||
}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
|
||||
>
|
||||
Reconciliation →
|
||||
</.link>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -147,7 +167,7 @@
|
|||
field={@form[:api_key]}
|
||||
type="password"
|
||||
label="API Key"
|
||||
placeholder="Enter your Preseem API key"
|
||||
placeholder={"Enter your #{provider.name} API key"}
|
||||
autocomplete="off"
|
||||
value={get_credential(@integrations[provider.id], "api_key")}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue