Skip to content

Commit

Permalink
Support admin user view page.
Browse files Browse the repository at this point in the history
Signed-off-by: EdmondFrank <[email protected]>
  • Loading branch information
EdmondFrank committed May 23, 2024
1 parent 5310582 commit 2c4ce78
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion backoffice
9 changes: 9 additions & 0 deletions lib/compass_admin_web/live/backoffice/layout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ defmodule CompassAdminWeb.Live.Backoffice.Layout do
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
"""
},
%{
label: "User",
link: "/admin/users",
icon: """
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
</svg>
"""
}
]
end
Expand Down
19 changes: 19 additions & 0 deletions lib/compass_admin_web/live/user_live.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule CompassAdminWeb.UserLive do
use Backoffice.Resource.Index,
resolver: Backoffice.Resolvers.Ecto,
resolver_opts: [
repo: CompassAdmin.Repo,
# Use preload and order_by
preload: [:login_binds],
order_by: :id
],
resource: CompassAdmin.User

index do
field :id
field :role_level
field :anonymous, :boolean
field :email, :string
field :name, :string
end
end
29 changes: 7 additions & 22 deletions lib/compass_admin_web/router.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule CompassAdminWeb.Router do
use CompassAdminWeb, :router

import Phoenix.LiveDashboard.Router

pipeline :browser do
plug :accepts, ["html"]
Expand All @@ -19,38 +20,22 @@ defmodule CompassAdminWeb.Router do
scope "/admin", CompassAdminWeb do
pipe_through :browser
live "/", PageLive, :index
live "/users", UserLive
live "/dockers", DockerServicesLive, :index
live "/deployments/backend", BackendDeploymentLive, :index
live "/deployments/frontend", FrontendDeploymentLive, :index
end

scope "/debug", CompassAdminWeb do
pipe_through :api
match :*, "/webhook", DebugController, :webhook
end

# Other scopes may use custom stacks.
# scope "/api", CompassAdminWeb do
# pipe_through :api
# end

# Enables LiveDashboard only for development
#
# If you want to use the LiveDashboard in production, you should put
# it behind authentication and allow only admins to access it.
# If your application does not have an admins-only section yet,
# you can use Plug.BasicAuth to set up some basic authentication
# as long as you are also using SSL (which you should anyway).
import Phoenix.LiveDashboard.Router

scope "/admin" do
pipe_through :browser
live_dashboard "/dashboard",
metrics: CompassAdminWeb.Telemetry,
ecto_repos: [CompassAdmin.Repo],
ecto_mysql_extras_options: [long_running_queries: [threshold: 200]]
end

scope "/debug", CompassAdminWeb do
pipe_through :api
match :*, "/webhook", DebugController, :webhook
end

# Enables the Swoosh mailbox preview in development.
#
# Note that preview only shows emails that were sent by the same
Expand Down

0 comments on commit 2c4ce78

Please sign in to comment.