Custom signatures (#37)

* feat(signatures): Add custom info to system signatures

* feat(connections): Add custom info to system connections

* feat(Map): Add system signature type

* feat(Map): Update wormhole types info

* feat(Map): Add undo action for removed systems

* feat(Map): Delete systems on Backspace hotkey

* feat(Map): Update k-space systems background & styles

* feat(Map): Update systems status background styles

* feat(Map): add support for new wh type data. add signatures settings modal menu; reworked signatures widget - was added info of wormhole;

---------

Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai>
This commit is contained in:
Dmitry Popov
2024-10-24 13:10:17 +04:00
committed by GitHub
parent 005068de9c
commit cb41a33546
76 changed files with 3642 additions and 1210 deletions

View File

@@ -1,62 +1,92 @@
defmodule WandererAppWeb.UserActivity do
use WandererAppWeb, :live_component
use LiveViewEvents
attr(:stream, :any, required: true)
attr(:page, :integer, required: true)
attr(:end_of_stream?, :boolean, required: true)
@impl true
def mount(socket) do
{:ok, socket}
end
def list(assigns) do
@impl true
def update(assigns,
socket
) do
{:ok,
socket
|> handle_info_or_assign(assigns)}
end
# attr(:can_undo_types, :list, required: false)
# attr(:stream, :any, required: true)
# attr(:page, :integer, required: true)
# attr(:end_of_stream?, :boolean, required: true)
def render(assigns) do
~H"""
<span
:if={@page > 1}
class="text-1xl fixed bottom-10 right-10 bg-zinc-700 text-white rounded-lg p-1 text-center min-w-[65px] z-50 opacity-70"
>
<%= @page %>
</span>
<ul
id="events"
class="space-y-4"
phx-update="stream"
phx-viewport-top={@page > 1 && "prev-page"}
phx-viewport-bottom={!@end_of_stream? && "next-page"}
phx-page-loading
class={[
if(@end_of_stream?, do: "pb-10", else: "pb-[calc(200vh)]"),
if(@page == 1, do: "pt-10", else: "pt-[calc(200vh)]")
]}
>
<li :for={{dom_id, activity} <- @stream} id={dom_id}>
<.activity_entry activity={activity} />
</li>
</ul>
<div :if={@end_of_stream?} class="mt-5 text-center">
No more activity
<div id={@id}>
<span
:if={@page > 1}
class="text-1xl fixed bottom-10 right-10 bg-zinc-700 text-white rounded-lg p-1 text-center min-w-[65px] z-50 opacity-70"
>
<%= @page %>
</span>
<ul
id="events"
class="space-y-4"
phx-update="stream"
phx-viewport-top={@page > 1 && "prev-page"}
phx-viewport-bottom={!@end_of_stream? && "next-page"}
phx-page-loading
class={[
if(@end_of_stream?, do: "pb-10", else: "pb-[calc(200vh)]"),
if(@page == 1, do: "pt-10", else: "pt-[calc(200vh)]")
]}
>
<li :for={{dom_id, activity} <- @stream} id={dom_id}>
<.activity_entry activity={activity} can_undo_types={@can_undo_types} />
</li>
</ul>
<div :if={@end_of_stream?} class="mt-5 text-center">
No more activity
</div>
</div>
"""
end
attr(:activity, WandererApp.Api.UserActivity, required: true)
attr(:can_undo_types, :list, required: false)
defp activity_entry(%{} = assigns) do
~H"""
<div class="flex w-full items-center justify-between space-x-2">
<div class="flex items-center space-x-3 text-xs">
<div class="flex items-center w-full space-x-2 p-1 hover:bg-gray-900">
<div class="flex items-center text-xs w-[270px]">
<p class="flex items-center space-x-1">
<span class="w-[150px] line-clamp-1 block text-sm font-normal leading-none text-gray-400 dark:text-gray-500">
<.local_time id={@activity.id} at={@activity.inserted_at} />
</span>
</p>
<p
:if={not is_nil(@activity.character)}
class="flex shrink-0 items-center space-x-1 min-w-[200px]"
>
<.character_item character={@activity.character} />
</p>
</div>
<p class="text-sm leading-[150%] text-[var(--color-gray-4)]">
<.character_item :if={not is_nil(@activity.character)} character={@activity.character} />
<p :if={is_nil(@activity.character)} class="text-sm text-[var(--color-gray-4)] w-[150px]">
System user / Administrator
</p>
<p class="text-sm text-[var(--color-gray-4)] w-[15%]">
<%= _get_event_name(@activity.event_type) %>
</p>
<.activity_event event_type={@activity.event_type} event_data={@activity.event_data} />
<div :if={@activity.event_type in @can_undo_types}>
<button
phx-click="undo"
phx-value-event-data={@activity.event_data}
phx-value-event-type={@activity.event_type}
class="btn btn-sm btn-icon"
>
<.icon name="hero-arrow-uturn-left-solid" class="h-5 w-5" /> Undo
</button>
</div>
</div>
"""
end
@@ -65,7 +95,7 @@ defmodule WandererAppWeb.UserActivity do
def character_item(assigns) do
~H"""
<div class="flex items-center gap-3 text-sm">
<div class="flex items-center gap-3 text-sm w-[150px]">
<div class="avatar">
<div class="rounded-md w-8 h-8">
<img src={member_icon_url(@character.eve_id)} alt={@character.name} />
@@ -86,11 +116,20 @@ defmodule WandererAppWeb.UserActivity do
<h6 class="text-base leading-[150%] font-semibold dark:text-white">
<%= _get_event_data(@event_type, Jason.decode!(@event_data) |> Map.drop(["character_id"])) %>
</h6>
</div>
</div>
"""
end
@impl true
def handle_event("undo", %{"event-data" => event_data} = _params, socket) do
# notify_to(socket.assigns.notify_to, socket.assigns.event_name, map_slug)
IO.inspect(event_data)
{:noreply, socket}
end
defp _get_event_name(:hub_added), do: "Hub Added"
defp _get_event_name(:hub_removed), do: "Hub Removed"
defp _get_event_name(:map_connection_added), do: "Connection Added"