-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5d04da
commit 7cd634c
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,4 +190,6 @@ defmodule SwapifyApi.Tasks do | |
end | ||
end | ||
end | ||
|
||
def count_transfers(), do: TransferRepo.count() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
swapify_api/lib/swapify_api_web/controllers/admin_dashboard/index.html.heex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
Need to do something meaningful here | ||
<div class="flex w-full flex-col items-start justify-start gap-10"> | ||
<header class="flex flex-col items-start justify-start gap-2"> | ||
<.h1>Dashboard</.h1> | ||
</header> | ||
|
||
<.h2>App metrics</.h2> | ||
|
||
<div class="flex w-full flex-row flex-wrap items-start justify-start gap-2"> | ||
<.card_metric name="Users" value={@user_count} /> | ||
<.card_metric name="Transfers" value={@transfer_count} /> | ||
</div> | ||
</div> | ||
|
10 changes: 9 additions & 1 deletion
10
swapify_api/lib/swapify_api_web/controllers/admin_dashboard_controller.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
defmodule SwapifyApiWeb.AdminDashboardController do | ||
use SwapifyApiWeb, :controller | ||
|
||
alias SwapifyApi.Tasks | ||
alias SwapifyApi.Accounts | ||
|
||
plug :put_layout, {SwapifyApiWeb.Layouts, :admin} | ||
|
||
def index(conn, _), do: conn |> render(:index) | ||
def index(conn, _) do | ||
with {:ok, user_count} <- Accounts.count_users(), | ||
{:ok, transfer_count} <- Tasks.count_transfers() do | ||
conn |> render(:index, user_count: user_count, transfer_count: transfer_count) | ||
end | ||
end | ||
end |