neiam
/apollos_crib
It's Apollo's Crib
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions failure · Badges · Packages
⭐
Log in to mark this repository.
moving.
ea8055b · gmorell · 2022-07-31 19:45
Files changed
modified
.idea/libraries/healthchex.xml
+10
−0
@@ -7,11 +7,21 @@
| 7 | 7 | <root url="file://$PROJECT_DIR$/_build/dev/consolidated" /> |
| 8 | 8 | <root url="file://$PROJECT_DIR$/_build/dev/lib/healthchex/ebin" /> |
| 9 | 9 | <root url="file://$PROJECT_DIR$/_build/dev/consolidated" /> |
| 10 | + <root url="file://$PROJECT_DIR$/_build/dev/lib/healthchex/ebin" /> | |
| 11 | + <root url="file://$PROJECT_DIR$/_build/dev/consolidated" /> | |
| 12 | + <root url="file://$PROJECT_DIR$/_build/dev/lib/healthchex/ebin" /> | |
| 13 | + <root url="file://$PROJECT_DIR$/_build/dev/consolidated" /> | |
| 14 | + <root url="file://$PROJECT_DIR$/_build/dev/lib/healthchex/ebin" /> | |
| 15 | + <root url="file://$PROJECT_DIR$/_build/dev/consolidated" /> | |
| 16 | + <root url="file://$PROJECT_DIR$/_build/dev/lib/healthchex/ebin" /> | |
| 17 | + <root url="file://$PROJECT_DIR$/_build/dev/consolidated" /> | |
| 10 | 18 | </CLASSES> |
| 11 | 19 | <JAVADOC /> |
| 12 | 20 | <SOURCES> |
| 13 | 21 | <root url="file://$PROJECT_DIR$/deps/healthchex/lib" /> |
| 14 | 22 | <root url="file://$PROJECT_DIR$/deps/healthchex/lib" /> |
| 23 | + <root url="file://$PROJECT_DIR$/deps/healthchex/lib" /> | |
| 24 | + <root url="file://$PROJECT_DIR$/deps/healthchex/lib" /> | |
| 15 | 25 | </SOURCES> |
| 16 | 26 | </library> |
| 17 | 27 | </component> |
modified
apps/room_sanctum/lib/room_sanctum/configuration.ex
+12
−1
@@ -292,7 +292,7 @@ defmodule RoomSanctum.Configuration do
| 292 | 292 | |
| 293 | 293 | defp inj_fake_ids(attrs) do |
| 294 | 294 | q = attrs["queries"] |> Enum.map(fn {ctr, val} -> val |> Map.put("id", ctr) end) |
| 295 | − Map.put(attrs, "queries", q) |> IO.inspect() | |
| 295 | + Map.put(attrs, "queries", q) | |
| 296 | 296 | end |
| 297 | 297 | |
| 298 | 298 | @doc """ |
@@ -324,6 +324,17 @@ defmodule RoomSanctum.Configuration do
| 324 | 324 | Vision.changeset(vision, attrs) |
| 325 | 325 | end |
| 326 | 326 | |
| 327 | + # | |
| 328 | + def get_landing_vision() do | |
| 329 | + q = from v in Vision, | |
| 330 | + where: v.public == true, | |
| 331 | + order_by: fragment("RANDOM()"), | |
| 332 | + limit: 1 | |
| 333 | + q | |
| 334 | + |> Repo.one | |
| 335 | + end | |
| 336 | + | |
| 337 | + | |
| 327 | 338 | alias RoomSanctum.Configuration.Foci |
| 328 | 339 | |
| 329 | 340 | @doc """ |
modified
apps/room_sanctum/lib/room_sanctum_web/live/landing_live/index.ex
+51
−1
@@ -6,7 +6,15 @@ defmodule RoomSanctumWeb.LandingLive.Index do
| 6 | 6 | |
| 7 | 7 | @impl true |
| 8 | 8 | def mount(_params, _session, socket) do |
| 9 | − {:ok, assign(socket, :queries, [])} | |
| 9 | + vision = Configuration.get_landing_vision() | |
| 10 | + if connected?(socket), do: Process.send_after(self(), :update, 100) | |
| 11 | + { | |
| 12 | + :ok, | |
| 13 | + socket | |
| 14 | + |> assign(:vision, vision) | |
| 15 | + |> assign(:preview, []) | |
| 16 | + |> assign(:queries, []) | |
| 17 | + } | |
| 10 | 18 | end |
| 11 | 19 | |
| 12 | 20 | @impl true |
@@ -19,4 +27,46 @@ defmodule RoomSanctumWeb.LandingLive.Index do
| 19 | 27 | |> assign(:page_title, "Apollo's Crib") |
| 20 | 28 | end |
| 21 | 29 | |
| 30 | + def handle_info(:update, socket) do | |
| 31 | + Process.send_after(self(), :update, 10000) | |
| 32 | + %{data: data, queries: queries} = RoomSanctum.Worker.Vision.get_state(socket.assigns.vision.id) | |
| 33 | + { | |
| 34 | + :noreply, | |
| 35 | + socket | |
| 36 | + |> assign(:preview, data) | |
| 37 | + |> assign(:queries, queries) | |
| 38 | + } | |
| 39 | + end | |
| 40 | + | |
| 41 | + defp condense({id, type}, data) do | |
| 42 | + RoomSanctum.Condenser.BasicMQTT.condense({id, type}, data) | |
| 43 | + end | |
| 44 | + | |
| 45 | + def preview(condensed, {id, type}) do | |
| 46 | + %{data: condensed, id: id, type: type} | |
| 47 | + end | |
| 48 | + | |
| 49 | + defp icon(type) do | |
| 50 | + RoomSanctumWeb.IconHelpers.icon(type) | |
| 51 | + end | |
| 52 | + | |
| 53 | + defp get_query_data(item, queries, size \\ 8) do | |
| 54 | + as_map = queries | |
| 55 | + |> Enum.map(fn x -> {x.id, x} end) | |
| 56 | + |> Enum.into(%{}) | |
| 57 | + case Map.get(as_map, item) do | |
| 58 | + nil -> item | |
| 59 | + _val -> | |
| 60 | + case ( | |
| 61 | + _val.name | |
| 62 | + |> String.length > size) do | |
| 63 | + true -> | |
| 64 | + s = _val.name | |
| 65 | + |> String.slice(0, size) | |
| 66 | + s <> "..." | |
| 67 | + false -> | |
| 68 | + _val.name | |
| 69 | + end | |
| 70 | + end | |
| 71 | + end | |
| 22 | 72 | end |
modified
apps/room_sanctum/lib/room_sanctum_web/live/landing_live/index.html.heex
+17
−48
@@ -1,4 +1,4 @@
| 1 | −<div class="hero min-h-[80%] bg-accent-100 m-10 pt-12"> | |
| 1 | +<div class="min-h-[80%] bg-accent-100 m-10 pt-12"> | |
| 2 | 2 | <div class="hero-content text-center"> |
| 3 | 3 | <div class="max-w-md"> |
| 4 | 4 | <h1 class="text-5xl font-bold text-accent">Hello there</h1> |
@@ -17,59 +17,28 @@
| 17 | 17 | </div> |
| 18 | 18 | </div> |
| 19 | 19 | <div class="carousel rounded-box"> |
| 20 | − <div class="carousel-item w-1/5"> | |
| 21 | − <div class="card bg-base-100 shadow-xl m-4"> | |
| 22 | − <div class="card-body"> | |
| 23 | − <h2 class="card-title">DATA!</h2> | |
| 24 | − <p>If a dog chews shoes whose shoes does he choose?</p> | |
| 25 | − <div class="card-actions justify-end"> | |
| 26 | − <button class="btn btn-primary">Buy Now</button> | |
| 27 | − </div> | |
| 28 | − </div> | |
| 20 | + <%= for {k, p} <- @preview do %> | |
| 21 | + <div class="flex"> | |
| 22 | + <div class="w-16"> | |
| 23 | + <i class={"fas fa-fw fa-2xl #{icon(k |> elem(1))}"}></i> | |
| 29 | 24 | </div> |
| 30 | − </div> | |
| 31 | − <div class="carousel-item w-1/5"> | |
| 32 | − <div class="card bg-base-100 shadow-xl m-4"> | |
| 33 | − <div class="card-body"> | |
| 34 | − <h2 class="card-title">DATA!</h2> | |
| 35 | − <p>If a dog chews shoes whose shoes does he choose?</p> | |
| 36 | − <div class="card-actions justify-end"> | |
| 37 | − <button class="btn btn-primary">Buy Now</button> | |
| 38 | − </div> | |
| 39 | − </div> | |
| 40 | − </div> | |
| 41 | − </div> | |
| 42 | − <div class="carousel-item w-1/5"> | |
| 43 | − <div class="card bg-base-100 shadow-xl m-4"> | |
| 44 | − <div class="card-body"> | |
| 45 | − <h2 class="card-title">DATA!</h2> | |
| 46 | − <p>If a dog chews shoes whose shoes does he choose?</p> | |
| 47 | − <div class="card-actions justify-end"> | |
| 48 | − <button class="btn btn-primary">Buy Now</button> | |
| 49 | − </div> | |
| 50 | − </div> | |
| 51 | − </div> | |
| 52 | − </div> | |
| 53 | − <div class="carousel-item w-1/5"> | |
| 54 | − <div class="card bg-base-100 shadow-xl m-4"> | |
| 55 | − <div class="card-body"> | |
| 56 | − <h2 class="card-title">DATA!</h2> | |
| 57 | − <p>If a dog chews shoes whose shoes does he choose?</p> | |
| 58 | − <div class="card-actions justify-end"> | |
| 59 | − <button class="btn btn-primary">Buy Now</button> | |
| 60 | − </div> | |
| 61 | − </div> | |
| 25 | + <div class="w-7/8"> | |
| 26 | + <span class="text-secondary font-bold"><%= get_query_data(k |> elem(0), @queries, 64) %></span> | |
| 27 | + <pre><%= condense(k, p) |> Poison.encode!(pretty: true)%></pre> | |
| 62 | 28 | </div> |
| 63 | 29 | </div> |
| 64 | − <div class="carousel-item w-1/5"> | |
| 30 | + <div class="carousel-item w-1/4"> | |
| 65 | 31 | <div class="card bg-base-100 shadow-xl m-4"> |
| 66 | 32 | <div class="card-body"> |
| 67 | − <h2 class="card-title">DATA!</h2> | |
| 68 | − <p>If a dog chews shoes whose shoes does he choose?</p> | |
| 69 | − <div class="card-actions justify-end"> | |
| 70 | − <button class="btn btn-primary">Buy Now</button> | |
| 71 | − </div> | |
| 33 | + <h2 class="card-title"> | |
| 34 | + <i class={"fas fa-fw fa-xl #{icon(k |> elem(1))}"}></i> | |
| 35 | + <span class="text-secondary font-bold"><%= get_query_data(k |> elem(0), @queries, 64) %></span> | |
| 36 | + </h2> | |
| 37 | + <pre> | |
| 38 | + <%= condense(k, p) |> preview(k) |> Poison.encode!(pretty: true) %> | |
| 39 | + </pre> | |
| 72 | 40 | </div> |
| 73 | 41 | </div> |
| 74 | 42 | </div> |
| 43 | + <% end %> | |
| 75 | 44 | </div> |
added
apps/room_sanctum/lib/room_sanctum_web/live/live_preview.ex
+34
−0
@@ -0,0 +1,34 @@
| 1 | +defmodule RoomSanctumWeb.LivePreview do | |
| 2 | + import Phoenix.LiveView | |
| 3 | + import Phoenix.LiveView.Helpers | |
| 4 | + | |
| 5 | + alias Phoenix.LiveView.JS | |
| 6 | + | |
| 7 | + def p_gtfs(assigns) do | |
| 8 | + | |
| 9 | + end | |
| 10 | + | |
| 11 | + def p_gbfs(assigns) do | |
| 12 | + | |
| 13 | + end | |
| 14 | + | |
| 15 | + def p_tidal(assigns) do | |
| 16 | + | |
| 17 | + end | |
| 18 | + | |
| 19 | + def p_weather(assigns) do | |
| 20 | + | |
| 21 | + end | |
| 22 | + | |
| 23 | + def p_aqi(assigns) do | |
| 24 | + | |
| 25 | + end | |
| 26 | + | |
| 27 | + def p_ephem(assigns) do | |
| 28 | + | |
| 29 | + end | |
| 30 | + | |
| 31 | + def p_calendar(assigns) do | |
| 32 | + | |
| 33 | + end | |
| 34 | +end |
Parents: c5321bf