Skip to content

Commit e0aee6a

Browse files
committed
Add devices
1 parent 7df8e1d commit e0aee6a

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

fullstack/lib/fullstack_web/live/public/public_transactions.ex

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule FullstackWeb.Public.TransactionsLive.PublicTransactions do
22
use FullstackWeb, :live_view
33

4+
alias Fullstack.Devices
45
alias Fullstack.Financial
56
alias Contex.{BarChart, Plot, Dataset, Sparkline}
67
alias Contex
@@ -27,6 +28,7 @@ defmodule FullstackWeb.Public.TransactionsLive.PublicTransactions do
2728
socket =
2829
socket
2930
|> assign(:info, Financial.build_transactions_analytics(params))
31+
|> assign(:devices, Devices.list_devices())
3032
|> assign(:form, to_form(params))
3133
|> make_test_data()
3234
|> assign(
@@ -96,8 +98,8 @@ defmodule FullstackWeb.Public.TransactionsLive.PublicTransactions do
9698
defp make_red_plot(data) do
9799
Sparkline.new(data)
98100
|> Sparkline.colours("#fad48e", "#ff9838")
99-
|> Map.update!(:height, fn _ -> 100 end)
100-
|> Map.update!(:width, fn _ -> 200 end)
101+
|> Map.update!(:height, fn _ -> 60 end)
102+
|> Map.update!(:width, fn _ -> 150 end)
101103
|> Sparkline.draw()
102104
end
103105

fullstack/lib/fullstack_web/live/public/public_transactions.html.heex

+35-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,35 @@
77
<div class="md:p-2 p-1 w-1/2">
88
<%= make_plot(@info.daily_data, @bar_options, @selected_bar) %>
99
</div>
10-
<div class="md:p-2 p-1 w-2/4">
11-
<%= make_red_plot(@test_data) %>
10+
<div class="flex flex-wrap md:p-2 p-1 w-3/4">
11+
<div class="p-1 w-full">
12+
<div class="mx-auto max-w-screen-xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8">
13+
<dl class="mt-6 grid grid-cols-1 gap-4 sm:mt-8 sm:grid-cols-1 lg:grid-cols-2">
14+
<div class="flex flex-col rounded-lg bg-blue-50 px-4 py-8 text-center">
15+
<dt class="order-last text-lg font-medium text-gray-500">Total Transactions</dt>
16+
<dd class="text-xl font-extrabold text-blue-600 md:text-3xl">
17+
<%= @info.transactions_count %>
18+
</dd>
19+
</div>
20+
<div class="flex flex-col rounded-lg bg-blue-50 px-4 py-8 text-center">
21+
<dt class="order-last text-lg font-medium text-gray-500">Total Sales</dt>
22+
23+
<dd class="text-xl font-extrabold text-blue-600 md:text-2xl">
24+
$ <%= @info.total_amount %>
25+
</dd>
26+
</div>
27+
</dl>
28+
</div>
29+
</div>
30+
<div class="md:p-2 p-1 w-full">
31+
<.table id="devices" rows={@devices}>
32+
<:col :let={device} label="Identifier"><%= device.id %></:col>
33+
<:col :let={device} label="AVG speed">1 Mb</:col>
34+
<:col :let={device} label="">
35+
<%= make_red_plot(@test_data) %>
36+
</:col>
37+
</.table>
38+
</div>
1239
</div>
1340
<div class="md:p-2 p-1 w-1/4">
1441
<h2 class="font-medium title-font tracking-widest text-gray-900 mb-4 text-sm text-center sm:text-left">
@@ -32,9 +59,7 @@
3259
<%= customer %>
3360
</a>
3461
</nav>
35-
</div>
36-
<div class="md:p-2 p-1 w-1/4">
37-
<h2 class="font-medium title-font tracking-widest text-gray-900 mb-4 text-sm text-center sm:text-left">
62+
<h2 class="font-medium title-font tracking-widest text-gray-900 mt-10 mb-4 text-sm text-center sm:text-left">
3863
LAST CUSTOMERS
3964
</h2>
4065
<nav class="flex flex-col sm:items-start sm:text-left text-center items-center -mb-1 space-y-2.5">
@@ -57,8 +82,10 @@
5782
</nav>
5883
</div>
5984
</div>
60-
<pre>
61-
<%= inspect(@info.transactions_count) %>
62-
<%= inspect(@info.total_amount) %>
85+
<div class="items-center ">
86+
<pre class="text-gray-300 bg-gray-800 code p-4 rounded-md whitespace-pre overflow-x-auto">
87+
<code> <%= inspect(@info.daily_data, pretty: true) %>
88+
</code>
6389
</pre>
90+
</div>
6491
</div>

0 commit comments

Comments
 (0)