Put some stats on the home page
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
defmodule MusicLibraryWeb.StatsController do
|
||||
use MusicLibraryWeb, :controller
|
||||
|
||||
alias MusicLibrary.Records
|
||||
|
||||
def index(conn, _params) do
|
||||
records_count = Records.count_records()
|
||||
render(conn, :index, records_count: records_count)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
defmodule MusicLibraryWeb.StatsHTML do
|
||||
use MusicLibraryWeb, :html
|
||||
|
||||
embed_templates "stats_html/*"
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
<div>
|
||||
<h1 class="text-base font-semibold leading-6 text-gray-900">Music Library</h1>
|
||||
<dl class="mt-5 grid grid-cols-1 divide-y divide-gray-200 overflow-hidden rounded-lg bg-white shadow md:grid-cols-3 md:divide-x md:divide-y-0">
|
||||
<div class="px-4 py-5 sm:p-6">
|
||||
<dt class="text-base font-normal text-gray-900">Total Records</dt>
|
||||
<dd class="mt-1 flex items-baseline justify-between md:block lg:flex">
|
||||
<div class="flex items-baseline text-2xl font-semibold text-indigo-600">
|
||||
<%= @records_count %>
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
@@ -19,8 +19,8 @@ defmodule MusicLibraryWeb.Router do
|
||||
|
||||
get "/health", HealthController, :index
|
||||
get "/images/:record_id", ImageController, :show
|
||||
get "/", StatsController, :index
|
||||
|
||||
live "/", RecordLive.Index, :index
|
||||
live "/records", RecordLive.Index, :index
|
||||
live "/records/import", RecordLive.Index, :import
|
||||
live "/records/:id/edit", RecordLive.Index, :edit
|
||||
|
||||
Reference in New Issue
Block a user