Add service restart, start/stop buttons. Fix status icons.

This commit is contained in:
Harshad Sharma 2024-05-16 23:04:53 +05:30
parent 80a8efd582
commit b522b3381f

View file

@ -86,28 +86,84 @@ defmodule FreediveWeb.ServiceLive.Components do
<:actions>
<div class="columns">
<div class="column is-narrow">
<.icon for="running" color="auto" aria-hidden="true" />
<.icon for="enabled" color="auto" aria-hidden="true" />
<%= if @selected_item.running do %>
<.icon for="circle-play" color="green" aria-hidden="true" />
<% else %>
<.icon for="circle-stop" color="red" aria-hidden="true" />
<% end %>
<%= if @selected_item.enabled do %>
<.icon for="circle-check" color="green" aria-hidden="true" />
<% else %>
<.icon for="circle-x" color="red" aria-hidden="true" />
<% end %>
</div>
</div>
</:actions>
</.panel_media>
<.panel_media>
<:icon>
<%!-- <.icon for="terminal" color="auto" size="3rem" aria-hidden="true" /> --%>
</:icon>
<:actions>
<div class="columns is-mobile">
<%= if @selected_item.running do %>
<div class="column is-narrow">
<button
class="button is-warning"
>
Restart
</button>
</div>
<div class="column">
<button class="button is-danger">
Stop
</button>
</div>
<% else %>
<div class="column">
<button class="button is-success">
Start
</button>
</div>
<% end %>
</div>
</:actions>
<%= if @selected_item.commands do %>
<%= for command <- @selected_item.commands do %>
<button
class="button is-info"
phx-click="command"
phx-value-name={@selected_item.name}
phx-value-command={command}
>
<%= command %>
</button>
<% end %>
<% end %>
</.panel_media>
"""
end
def items_block(assigns) do
~H"""
<%= for {_name, item} <- @items do %>
<.link
class={"panel-block pt-1 #{if @selected_item != nil and @selected_item.name == item.name, do: "has-background-info-light"}"}
phx-click="tap"
phx-value-name={item.name}
>
<span class="panel-icon">
<.icon for={item.icon} color="auto" aria-hidden="true" />
</span>
<div class="mt-2 ml-2"><%= item.name %></div>
</.link>
<div>
<.link
class={"panel-block pt-1 #{if @selected_item != nil and @selected_item.name == item.name, do: "has-background-info-light"}"}
phx-click="tap"
phx-value-name={item.name}
>
<span class="panel-icon">
<.icon for={item.icon} color="auto" aria-hidden="true" />
</span>
<div class="mt-2 ml-2">
<%= item.name %>
</div>
</.link>
</div>
<% end %>
"""
end