diff --git a/.gitignore b/.gitignore index 3990998a..b7f1e23f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ k8s/.envrc # TODO tracking (personal notes, not for version control) TODOS.md + +# SNMP profiles export (temporary/local data) +profiles.json diff --git a/lib/towerops/api_tokens.ex b/lib/towerops/api_tokens.ex index 312fbb76..c4fe7182 100644 --- a/lib/towerops/api_tokens.ex +++ b/lib/towerops/api_tokens.ex @@ -58,6 +58,22 @@ defmodule Towerops.ApiTokens do |> Repo.all() end + @doc """ + Lists all API tokens created by a user across all organizations. + + ## Examples + + iex> list_user_api_tokens(user_id) + [%ApiToken{}, ...] + """ + def list_user_api_tokens(user_id) do + ApiToken + |> where([t], t.user_id == ^user_id) + |> order_by([t], desc: t.inserted_at) + |> preload(:organization) + |> Repo.all() + end + @doc """ Gets a single API token by ID. diff --git a/lib/towerops_web/components/core_components.ex b/lib/towerops_web/components/core_components.ex index 03fc1f9b..f1b1deab 100644 --- a/lib/towerops_web/components/core_components.ex +++ b/lib/towerops_web/components/core_components.ex @@ -54,62 +54,45 @@ defmodule ToweropsWeb.CoreComponents do id={@id} phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")} role="alert" + aria-live="assertive" class="pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 z-50" {@rest} >
-
+
-
+
<.icon :if={@kind == :info} - name="hero-information-circle" - class="h-6 w-6 text-blue-600 dark:text-blue-400" + name="hero-check-circle" + class="size-6 text-green-400" /> <.icon :if={@kind == :error} - name="hero-exclamation-circle" - class="h-6 w-6 text-red-600 dark:text-red-400" + name="hero-x-circle" + class="size-6 text-red-400" />
-

+

{@title}

{msg}

-
+
@@ -283,21 +266,21 @@ defmodule ToweropsWeb.CoreComponents do def input(%{type: "select"} = assigns) do ~H"""
-
""" @@ -433,17 +429,17 @@ defmodule ToweropsWeb.CoreComponents do end ~H""" -
- - +
+
+ - @@ -451,24 +447,25 @@ defmodule ToweropsWeb.CoreComponents do - + -
{col[:label]} + {gettext("Actions")}
0 && "px-3 text-gray-500 dark:text-gray-400", @row_click && "cursor-pointer" ]} > {render_slot(col, @row_item.(row))} +
<%= for action <- @action do %> {render_slot(action, @row_item.(row))} diff --git a/lib/towerops_web/components/layouts.ex b/lib/towerops_web/components/layouts.ex index d6b85096..36e220fb 100644 --- a/lib/towerops_web/components/layouts.ex +++ b/lib/towerops_web/components/layouts.ex @@ -176,22 +176,34 @@ defmodule ToweropsWeb.Layouts do type="button" id="org-menu-button" phx-click={JS.toggle(to: "#org-menu")} - class="flex items-center gap-2 text-sm font-medium text-zinc-700 hover:text-zinc-900 dark:text-zinc-300 dark:hover:text-zinc-100" + class="inline-flex items-center justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs inset-ring-1 inset-ring-gray-300 hover:bg-gray-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20" > {if @current_organization, do: @current_organization.name, else: "Menu"} - <.icon name="hero-chevron-down" class="h-4 w-4" /> +