neiam
/lambent_ex
Lambent Aether 5
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
icon redo, wiring for previews and still working on the actual html
455dae1 · gmorell · 2023-01-11 06:20
Files changed
modified
assets/js/app.js
+10
−0
@@ -40,3 +40,13 @@ liveSocket.connect()
| 40 | 40 | // >> liveSocket.disableLatencySim() |
| 41 | 41 | window.liveSocket = liveSocket |
| 42 | 42 | |
| 43 | +// | |
| 44 | +import "popper" | |
| 45 | +import { Tooltip } from "@popperjs/core" | |
| 46 | + | |
| 47 | +var tooltipTriggerList = [].slice.call( | |
| 48 | + document.querySelectorAll('[data-bs-toggle="tooltip"]') | |
| 49 | +); | |
| 50 | +var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { | |
| 51 | + return new Tooltip(tooltipTriggerEl); | |
| 52 | +}); |
modified
assets/package-lock.json
+10
−0
@@ -6,6 +6,7 @@
| 6 | 6 | "": { |
| 7 | 7 | "dependencies": { |
| 8 | 8 | "@fortawesome/fontawesome-free": "^6.2.1", |
| 9 | + "@popperjs/core": "^2.11.6", | |
| 9 | 10 | "daisyui": "^2.43.0" |
| 10 | 11 | } |
| 11 | 12 | }, |
@@ -50,6 +51,15 @@
| 50 | 51 | "node": ">= 8" |
| 51 | 52 | } |
| 52 | 53 | }, |
| 54 | + "node_modules/@popperjs/core": { | |
| 55 | + "version": "2.11.6", | |
| 56 | + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", | |
| 57 | + "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==", | |
| 58 | + "funding": { | |
| 59 | + "type": "opencollective", | |
| 60 | + "url": "https://opencollective.com/popperjs" | |
| 61 | + } | |
| 62 | + }, | |
| 53 | 63 | "node_modules/acorn": { |
| 54 | 64 | "version": "7.4.1", |
| 55 | 65 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", |
modified
assets/package.json
+1
−0
@@ -1,6 +1,7 @@
| 1 | 1 | { |
| 2 | 2 | "dependencies": { |
| 3 | 3 | "@fortawesome/fontawesome-free": "^6.2.1", |
| 4 | + "@popperjs/core": "^2.11.6", | |
| 4 | 5 | "daisyui": "^2.43.0" |
| 5 | 6 | } |
| 6 | 7 | } |
modified
lib/lambent_ex/machine.ex
+2
−0
@@ -6,6 +6,7 @@ defmodule LambentEx.Machine do
| 6 | 6 | |
| 7 | 7 | @pubsub_name LambentEx.PubSub |
| 8 | 8 | @pubsub_topic "machine-" |
| 9 | + @pubsub_topic_fh "machine:" | |
| 9 | 10 | @pubsub_topic_idx "machines_idx" |
| 10 | 11 | |
| 11 | 12 | @speeds %{ |
@@ -164,6 +165,7 @@ defmodule LambentEx.Machine do
| 164 | 165 | end |
| 165 | 166 | |
| 166 | 167 | Phoenix.PubSub.broadcast(@pubsub_name, @pubsub_topic <> state[:name], {:publish, data}) |
| 168 | + Phoenix.PubSub.broadcast(@pubsub_name, @pubsub_topic_fh, {:firehose, {state[:name], data |> Enum.slice(0..50)}}) | |
| 167 | 169 | {:noreply, bright_step(state)} |
| 168 | 170 | end |
| 169 | 171 |
modified
lib/lambent_ex/meta.ex
+0
−4
@@ -90,8 +90,6 @@ defmodule LambentEx.Meta do
| 90 | 90 | |
| 91 | 91 | def handle_info(:link_flush, state) do |
| 92 | 92 | Process.send_after(self(), :link_flush, 5000) |
| 93 | − IO.puts("flushen") | |
| 94 | − IO.inspect(state.links) | |
| 95 | 93 | if state.links |> MapSet.size() == 0 do |
| 96 | 94 | {:noreply, state} |
| 97 | 95 | else |
@@ -106,7 +104,6 @@ defmodule LambentEx.Meta do
| 106 | 104 | {:noreply, %{state | machines: MapSet.put(state.machines, machine)}} |
| 107 | 105 | |
| 108 | 106 | false -> |
| 109 | −# IO.inspect(machine) | |
| 110 | 107 | {:noreply, |
| 111 | 108 | %{state | machines: MapSet.delete(state.machines, machine |> Map.put(:persist, true) |> Map.put(:opts, machine[:opts] |> Keyword.update(:persist, true, fn _ -> true end)))}} |
| 112 | 109 | end |
@@ -118,7 +115,6 @@ defmodule LambentEx.Meta do
| 118 | 115 | {:noreply, %{state | links: MapSet.put(state.links, link)}} |
| 119 | 116 | |
| 120 | 117 | false -> |
| 121 | − # IO.inspect(machine) | |
| 122 | 118 | {:noreply, |
| 123 | 119 | %{state | links: MapSet.delete(state.links, link |> Map.put(:persist, true) |> Map.put(:opts, link[:opts] |> Keyword.update(:persist, true, fn _ -> true end)))}} |
| 124 | 120 | end |
modified
lib/lambent_ex_web/live/links/index.html.heex
+8
−5
@@ -41,17 +41,20 @@ on_cancel={JS.navigate(~p"/cfg/links")}>
| 41 | 41 | <td><%= v[:target] %></td> |
| 42 | 42 | <td> |
| 43 | 43 | <%= if v[:enabled] == true do %> |
| 44 | − <input type="checkbox" phx-click="toggle" phx-value-tgt={k} class="toggle mb-4" checked /> | |
| 44 | + <a class="btn btn-secondary btn-outline btn-circle"phx-click="toggle" phx-value-tgt={k}> | |
| 45 | + <i class="fa-solid fa-2x fa-cog fa-spin"></i> | |
| 46 | + </a> | |
| 45 | 47 | <% else %> |
| 46 | − <input type="checkbox" phx-click="toggle" phx-value-tgt={k} class="toggle mb-4" /> | |
| 48 | + <a class="btn btn-primary btn-outline btn-circle"phx-click="toggle" phx-value-tgt={k}> | |
| 49 | + <i class="fa-solid fa-2x fa-cog"></i> | |
| 50 | + </a> | |
| 47 | 51 | <% end %> |
| 48 | −   | |
| 49 | 52 | <%= if v[:persist] == true do %> |
| 50 | − <a class="btn btn-success btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 53 | + <a class="btn btn-accent btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 51 | 54 | <i class="fa-solid fa-2x fa-thumbtack"></i> |
| 52 | 55 | </a> |
| 53 | 56 | <% else %> |
| 54 | − <a class="btn btn-success btn-outline btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 57 | + <a class="btn btn-accent btn-outline btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 55 | 58 | <i class="fa-solid fa-2x fa-thumbtack"></i> |
| 56 | 59 | </a> |
| 57 | 60 | <% end %> |
modified
lib/lambent_ex_web/live/machines/index.ex
+16
−0
@@ -4,6 +4,7 @@ defmodule LambentExWeb.MachinesLive.Index do
| 4 | 4 | alias LambentExWeb.MachinesLive.Index |
| 5 | 5 | |
| 6 | 6 | @pubsub_name LambentEx.PubSub |
| 7 | + @pubsub_topic_fh "machine:" | |
| 7 | 8 | |
| 8 | 9 | use Phoenix.LiveEditableView |
| 9 | 10 | alias LambentEx.LiveEdit |
@@ -27,9 +28,11 @@ defmodule LambentExWeb.MachinesLive.Index do
| 27 | 28 | @impl true |
| 28 | 29 | def mount(_params, _session, socket) do |
| 29 | 30 | Phoenix.PubSub.subscribe(@pubsub_name, "machines_idx") |
| 31 | + Phoenix.PubSub.subscribe(@pubsub_name, @pubsub_topic_fh) | |
| 30 | 32 | {:ok, socket |
| 31 | 33 | |> assign(:machine, nil) |
| 32 | 34 | |> assign(:machines, %{}) |
| 35 | + |> assign(:previews, %{}) | |
| 33 | 36 | |> assign(:nonew, true) |
| 34 | 37 | |> assign(:newctrl, [ |
| 35 | 38 | %{link: ~p"/cfg/machines/new", icon: "plus"}, |
@@ -62,6 +65,10 @@ defmodule LambentExWeb.MachinesLive.Index do
| 62 | 65 | {:noreply, socket |> assign(:machines, socket.assigns.machines |> Map.put(machine[:id], machine))} |
| 63 | 66 | end |
| 64 | 67 | |
| 68 | + def handle_info({:firehose, {name, data}}, socket) do | |
| 69 | + {:noreply, socket |> assign(:previews, socket.assigns.previews |> Map.put(name, data))} | |
| 70 | + end | |
| 71 | + | |
| 65 | 72 | def handle_event("faster", data, socket) do |
| 66 | 73 | LambentEx.Machine.faster(data["id"]) |
| 67 | 74 | {:noreply, socket} |
@@ -101,4 +108,13 @@ defmodule LambentExWeb.MachinesLive.Index do
| 101 | 108 | val/255 * 100 |> trunc |
| 102 | 109 | end |
| 103 | 110 | |
| 111 | + defp preview(pile, name) do | |
| 112 | + chunks = pile |> Map.get(name, []) |> Enum.chunk_every(3) |> Enum.map( fn [r,g,b] -> "<div style='background-color: rgb(#{r},#{g},#{b})'> </div>" end) | |
| 113 | + """ | |
| 114 | + <div class='grid grid-cols-1 gap-4'> | |
| 115 | + #{chunks} | |
| 116 | + </div> | |
| 117 | + """ | |
| 118 | + end | |
| 119 | + | |
| 104 | 120 | end |
modified
lib/lambent_ex_web/live/machines/index.html.heex
+9
−6
@@ -42,11 +42,14 @@
| 42 | 42 | <td><%= v[:speed] |> spd %></td> |
| 43 | 43 | <td><%= v[:bgt] |> bgt %> %</td> |
| 44 | 44 | <td> |
| 45 | + <button class="btn btn-circle" data-bs-toggle="tooltip" data-bs-html="true" title={preview(@previews, v[:name])}> | |
| 46 | + <i class="fa-solid fa-2x fa-magnifying-glass"></i> | |
| 47 | + </button> | |
| 45 | 48 | <button class="btn btn-circle" phx-click="slower" phx-value-id={v[:name] }> |
| 46 | − <i class="fa-solid fa-2x fa-circle-minus"></i> | |
| 49 | + <i class="fa-solid fa-2x fa-forward-step"></i> | |
| 47 | 50 | </button> |
| 48 | 51 | <button class="btn btn-circle" phx-click="faster" phx-value-id={v[:name] }> |
| 49 | − <i class="fa-solid fa-2x fa-circle-plus"></i> | |
| 52 | + <i class="fa-solid fa-2x fa-forward-fast"></i> | |
| 50 | 53 | </button> |
| 51 | 54 | <button class="btn btn-circle" phx-click="dimmer" phx-value-id={v[:name] }> |
| 52 | 55 | <i class="fa-regular fa-2x fa-lightbulb"></i> |
@@ -55,12 +58,12 @@
| 55 | 58 | <i class="fa-solid fa-2x fa-lightbulb"></i> |
| 56 | 59 | </button> |
| 57 | 60 | <%= if v[:persist] == true do %> |
| 58 | − <a class="btn btn-success btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 59 | − <i class="fa-solid fa-2x fa-anchor"></i> | |
| 61 | + <a class="btn btn-accent btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 62 | + <i class="fa-solid fa-2x fa-thumbtack"></i> | |
| 60 | 63 | </a> |
| 61 | 64 | <% else %> |
| 62 | − <a class="btn btn-success btn-outline btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 63 | − <i class="fa-solid fa-2x fa-anchor"></i> | |
| 65 | + <a class="btn btn-accent btn-outline btn-circle" phx-click="persist" phx-value-tgt={v[:name]}> | |
| 66 | + <i class="fa-solid fa-2x fa-thumbtack"></i> | |
| 64 | 67 | </a> |
| 65 | 68 | <% end %> |
| 66 | 69 | <a class="btn btn-error btn-outline btn-circle" phx-click="quit" phx-value-tgt={v[:name]}> |
Parents: abf0ff7