Useful data on homepage v1 (#43)

* Made the homepage _slightly_ more useful

* Very minor refactor in alpine body-level object
This commit is contained in:
Kieran 2024-03-01 18:25:55 -08:00 committed by GitHub
parent be8bcf0eb2
commit 36f27c76e8
3 changed files with 36 additions and 7 deletions

View file

@ -12,7 +12,7 @@
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
</script>
</head>
<body x-data="{ 'sidebarVisible': false }" class="dark text-bodydark bg-boxdark-2">
<body x-data="{ sidebarVisible: false }" class="dark text-bodydark bg-boxdark-2">
<%= @inner_content %>
</body>
</html>

View file

@ -1,8 +1,10 @@
defmodule PinchflatWeb.Pages.PageController do
alias Pinchflat.Media.MediaItem
use PinchflatWeb, :controller
alias Pinchflat.Repo
alias Pinchflat.Sources.Source
alias Pinchflat.Media.MediaItem
alias Pinchflat.Profiles.MediaProfile
def home(conn, params) do
@ -18,9 +20,17 @@ defmodule PinchflatWeb.Pages.PageController do
end
defp render_home_page(conn) do
media_profile_count = Repo.aggregate(MediaProfile, :count, :id)
source_count = Repo.aggregate(Source, :count, :id)
media_item_count = Repo.aggregate(MediaItem, :count, :id)
conn
|> put_session(:onboarding, false)
|> render(:home)
|> render(:home,
media_profile_count: media_profile_count,
source_count: source_count,
media_item_count: media_item_count
)
end
defp render_onboarding_page(conn, media_profiles_exist, sources_exist) do

View file

@ -1,8 +1,27 @@
<div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10 text-center my-10">
<h2 class="text-2xl">TODO: Put some useful info or analytics here</h2>
<p>For now, the options in the sidebar have what you need</p>
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
<div class="rounded-sm border px-7.5 py-6 shadow-default border-strokedark bg-boxdark">
<div class="mt-4 flex flex-col items-center justify-center">
<span class="text-md font-medium">Media Profile(s)</span>
<h4 class="text-title-md font-bold text-white">
<%= @media_profile_count %>
</h4>
</div>
</div>
<div class="rounded-sm border px-7.5 py-6 shadow-default border-strokedark bg-boxdark">
<div class="mt-4 flex flex-col items-center justify-center">
<span class="text-md font-medium">Source(s)</span>
<h4 class="text-title-md font-bold text-white">
<%= @source_count %>
</h4>
</div>
</div>
<div class="rounded-sm border px-7.5 py-6 shadow-default border-strokedark bg-boxdark">
<div class="mt-4 flex flex-col items-center justify-center">
<span class="text-md font-medium">Media Item(s)</span>
<h4 class="text-title-md font-bold text-white">
<%= @media_item_count %>
</h4>
</div>
</div>
<span class="text-strokedark">I know this page isn't super useful yet, but give it time :&rpar;</span>
</div>