diff --git a/lib/freedive/api/service/server.ex b/lib/freedive/api/service/server.ex index 4d42bfe..55572fc 100644 --- a/lib/freedive/api/service/server.ex +++ b/lib/freedive/api/service/server.ex @@ -81,9 +81,7 @@ defmodule Freedive.Api.Service do broadcast(:stdlog, %{name: name, log: std_to_log(reason)}) end - if command in ["start", "stop", "restart"] do - broadcast(:refreshed, service_details(name)) - end + broadcast(:refreshed, service_details(name)) {:noreply, state} end diff --git a/lib/freedive_web/live/service_live.ex b/lib/freedive_web/live/service_live.ex index b730000..2b3923d 100644 --- a/lib/freedive_web/live/service_live.ex +++ b/lib/freedive_web/live/service_live.ex @@ -107,8 +107,7 @@ defmodule FreediveWeb.ServiceLive do socket |> assign(:selected_item, %{ socket.assigns.selected_item - | log: socket.assigns.selected_item.log ++ payload.log, - busy: false + | log: socket.assigns.selected_item.log ++ payload.log }) else socket @@ -137,6 +136,24 @@ defmodule FreediveWeb.ServiceLive.Components do attr :details, :string, default: nil, doc: "details" def items_block(%{details: true} = assigns) do + ~H""" + <.back_link selected_item={@selected_item} /> + <.service_header selected_item={@selected_item} /> + <.std_log selected_item={@selected_item} /> + <.basic_commands selected_item={@selected_item} /> + <.extra_commands selected_item={@selected_item} /> + """ + end + + def items_block(assigns) do + ~H""" + <%= for {_name, item} <- @items do %> + <.service_preview item={item} selected_item={@selected_item} /> + <% end %> + """ + end + + def back_link(assigns) do ~H""" <.link class="panel-block pt-1 has-background-light" @@ -148,9 +165,12 @@ defmodule FreediveWeb.ServiceLive.Components do
<%= Enum.join(@selected_item.log, "\n") %>
-
- <% end %>
+ def service_preview(assigns) do
+ ~H"""
+ <.panel_block
+ class={"#{if @selected_item != nil and @selected_item.name == @item.name, do: "pt-2 has-background-info-light", else: "pt-2"}"}
+ phx-click="tap"
+ phx-value-name={@item.name}
+ >
+ <.icon_raw for={@item.icon} color="auto" size="1.8rem" aria-hidden="true" />
+
+
+ <%= @item.name %>
+
+
+ <%= if @item.running do %>
+ <.icon for="circle-play" size="1rem" color="lightgreen" aria-hidden="true" />
+ <% else %>
+ <.icon for="circle-stop" size="1rem" color="gray" aria-hidden="true" />
+ <% end %>
+ <%= if @item.enabled do %>
+ <.icon for="circle-check" size="1rem" color="lightgreen" aria-hidden="true" />
+ <% else %>
+ <.icon for="circle-x" size="1rem" color="gray" aria-hidden="true" />
+ <% end %>
+
+ """
+ end
+
+ def basic_commands(assigns) do
+ ~H"""
<.panel_block_div>
<%= if @selected_item.running do %>
<.icon_raw for="power" color="lightgreen" size="2rem" class="ml-2 mr-5" aria-hidden="true" />
@@ -186,47 +232,58 @@ defmodule FreediveWeb.ServiceLive.Components do
<% end %>
<%= Enum.join(@selected_item.log, "\n") %>
<% end %>
"""
end
diff --git a/lib/liliform/page.ex b/lib/liliform/page.ex
index fd99b2c..2093a16 100644
--- a/lib/liliform/page.ex
+++ b/lib/liliform/page.ex
@@ -37,7 +37,9 @@ defmodule Liliform.Page do
phx-click="filter"
phx-value-key={filter.key}
>
- <%= filter.title %>
+
+ <%= filter.title %>
+
<% end %>
@@ -50,7 +52,11 @@ defmodule Liliform.Page do
phx-click="filter"
phx-value-key={filter.key}
>
- <.icon for={filter.icon} color={if filter.active, do: "gray", else: "auto"} />
+ <.icon_raw
+ for={filter.icon}
+ size="2rem"
+ color={if filter.active, do: "gray", else: "auto"}
+ />
<% end %>