Compare commits

..

22 Commits

Author SHA1 Message Date
CI
02d97a009c chore: release version v1.2.8 2024-10-06 13:13:12 +00:00
Ryan Olds
33940cdb9b Sortable signatures (#18)
feat(Signatures): Make signatures sortable
2024-10-06 17:12:47 +04:00
CI
7a63f9ee6b chore: release version v1.2.7 2024-10-05 07:55:07 +00:00
Dmitry Popov
89b41fff59 Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-05 11:54:38 +04:00
Dmitry Popov
7a15f71528 chore: release version v1.2.5 2024-10-05 11:54:35 +04:00
CI
cdce2f8761 chore: release version v1.2.6 2024-10-05 07:39:43 +00:00
Dmitry Popov
a2470bbe47 Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-05 11:39:17 +04:00
Dmitry Popov
dbdf1ddce0 fix(Core): Stability & performance improvements 2024-10-05 11:39:13 +04:00
CI
f767e42e6f chore: release version v1.2.5 2024-10-04 21:56:47 +00:00
Dmitry Popov
3051eb6369 Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-05 01:56:19 +04:00
Dmitry Popov
a41faddca3 fix(Core): Add system "true security" correction 2024-10-05 01:56:16 +04:00
CI
469038730e chore: release version v1.2.4 2024-10-03 09:27:53 +00:00
Dmitry Popov
b1fe5d2453 fix(Map): Remove duplicate connections 2024-10-03 13:27:21 +04:00
CI
f43e717da0 chore: release version v1.2.3 2024-10-02 17:52:44 +00:00
Dmitry Popov
95c8d4eef8 Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-02 21:52:08 +04:00
Dmitry Popov
747ca0ee82 fix(Map): Fix map loading after select a different map. 2024-10-02 21:52:04 +04:00
CI
35a0184ec3 chore: release version v1.2.2 2024-10-02 12:50:16 +00:00
Dmitry Popov
96e1e5328c Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-02 16:49:27 +04:00
Dmitry Popov
7f98d6a0d8 chore: release version v1.2.0 2024-10-02 16:49:23 +04:00
CI
0194e25696 chore: release version v1.2.1 2024-10-02 12:48:06 +00:00
Dmitry Popov
189442e50f Merge branch 'main' of github.com:wanderer-industries/wanderer 2024-10-02 16:47:34 +04:00
Dmitry Popov
d9bed070ec fix(ACL): Fix allowing to save map/access list with empty owner set 2024-10-02 16:47:29 +04:00
20 changed files with 297 additions and 269 deletions

2
.gitignore vendored
View File

@@ -12,6 +12,8 @@
# Ignore assets that are produced by build tools.
/priv/static/assets/
/priv/static/icons/
/priv/static/images/
/priv/static/*.js
/priv/static/*.css

View File

@@ -2,6 +2,66 @@
<!-- changelog -->
## [v1.2.8](https://github.com/wanderer-industries/wanderer/compare/v1.2.7...v1.2.8) (2024-10-06)
## [v1.2.7](https://github.com/wanderer-industries/wanderer/compare/v1.2.6...v1.2.7) (2024-10-05)
## [v1.2.6](https://github.com/wanderer-industries/wanderer/compare/v1.2.5...v1.2.6) (2024-10-05)
### Bug Fixes:
* Core: Stability & performance improvements
## [v1.2.5](https://github.com/wanderer-industries/wanderer/compare/v1.2.4...v1.2.5) (2024-10-04)
### Bug Fixes:
* Core: Add system "true security" correction
## [v1.2.4](https://github.com/wanderer-industries/wanderer/compare/v1.2.3...v1.2.4) (2024-10-03)
### Bug Fixes:
* Map: Remove duplicate connections
## [v1.2.3](https://github.com/wanderer-industries/wanderer/compare/v1.2.2...v1.2.3) (2024-10-02)
### Bug Fixes:
* Map: Fix map loading after select a different map.
## [v1.2.2](https://github.com/wanderer-industries/wanderer/compare/v1.2.1...v1.2.2) (2024-10-02)
## [v1.2.1](https://github.com/wanderer-industries/wanderer/compare/v1.2.0...v1.2.1) (2024-10-02)
### Bug Fixes:
* ACL: Fix allowing to save map/access list with empty owner set
## [v1.2.0](https://github.com/wanderer-industries/wanderer/compare/v1.1.0...v1.2.0) (2024-09-29)
@@ -31,60 +91,37 @@
## [v1.0.22](https://github.com/wanderer-industries/wanderer/compare/v1.0.21...v1.0.22) (2024-09-25)
### Bug Fixes:
### Bug Fixes
* Map: Main map doesn't load back after refreshing/switching pages
## [v1.0.21](https://github.com/wanderer-industries/wanderer/compare/v1.0.20...v1.0.21) (2024-09-24)
### Bug Fixes:
### Bug Fixes
* Map: Main map doesn't load back after refreshing/switching pages
## [v1.0.20](https://github.com/wanderer-industries/wanderer/compare/v1.0.19...v1.0.20) (2024-09-23)
### Bug Fixes:
### Bug Fixes
* core: Small fixes & improvements
## [v1.0.19](https://github.com/wanderer-industries/wanderer/compare/v1.0.18...v1.0.19) (2024-09-23)
### Bug Fixes:
### Bug Fixes
* ACL: Fix adding empty members list
## [v1.0.18](https://github.com/wanderer-industries/wanderer/compare/v1.0.17...v1.0.18) (2024-09-22)
### Bug Fixes:
### Bug Fixes
* ACL: Cant delete ACL list after map deletion #5
## [v1.0.17](https://github.com/wanderer-industries/wanderer/compare/v1.0.16...v1.0.17) (2024-09-21)
## [v1.0.16](https://github.com/wanderer-industries/wanderer/compare/v1.0.15...v1.0.16) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* Map: commented console log
@@ -94,103 +131,58 @@
## [v1.0.15](https://github.com/wanderer-industries/wanderer/compare/v1.0.14...v1.0.15) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* map: Show a proper user notification if map was deleted/archived
## [v1.0.14](https://github.com/wanderer-industries/wanderer/compare/v1.0.13...v1.0.14) (2024-09-21)
## [v1.0.13](https://github.com/wanderer-industries/wanderer/compare/v1.0.12...v1.0.13) (2024-09-21)
### Bug Fixes:
### Bug Fixes
* tracking: Ensure user has at least one character tracked to work with map
## [v1.0.12](https://github.com/wanderer-industries/wanderer/compare/v1.0.11...v1.0.12) (2024-09-20)
### Bug Fixes:
### Bug Fixes
* audit: Hide character for non-character map activities
## [v1.0.11](https://github.com/wanderer-industries/wanderer/compare/v1.0.10...v1.0.11) (2024-09-20)
## [v1.0.10](https://github.com/wanderer-industries/wanderer/compare/v1.0.9...v1.0.10) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* signatures: Fix update signatures error if no character tracked on map
## [v1.0.9](https://github.com/wanderer-industries/wanderer/compare/v1.0.8...v1.0.9) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* core: Fix system add error if it's already added on map
## [v1.0.8](https://github.com/wanderer-industries/wanderer/compare/v1.0.7...v1.0.8) (2024-09-19)
### Bug Fixes:
### Bug Fixes
* docker: Fix DB connection in docker-compose internal network
## [v1.0.7](https://github.com/wanderer-industries/wanderer/compare/v1.0.6...v1.0.7) (2024-09-19)
## [v1.0.6](https://github.com/wanderer-industries/wanderer/compare/v1.0.5...v1.0.6) (2024-09-18)
## [v1.0.5](https://github.com/wanderer-industries/wanderer/compare/v1.0.4...v1.0.5) (2024-09-18)
## [v1.0.4](https://github.com/wanderer-industries/wanderer/compare/v1.0.3...v1.0.4) (2024-09-18)
### Bug Fixes:
### Bug Fixes
* core: skip search results for failed character info request
## [v1.0.3](https://github.com/wanderer-industries/wanderer/compare/v1.0.2...v1.0.3) (2024-09-18)
## [v1.0.2](https://github.com/wanderer-industries/wanderer/compare/v1.0.1...v1.0.2) (2024-09-18)
## [v1.0.1](https://github.com/wanderer-industries/wanderer/compare/v1.0.0...v1.0.1) (2024-09-18)

View File

@@ -178,7 +178,7 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
resizableColumns
rowHover
selectAll
showHeaders={false}
sortField="eve_id"
onRowMouseEnter={handleEnterRow}
onRowMouseLeave={handleLeaveRow}
rowClassName={row => {
@@ -199,6 +199,7 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
field="group"
body={renderIcon}
style={{ maxWidth: 26, minWidth: 26, width: 26 }}
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
></Column>
<Column
@@ -206,12 +207,16 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
header="Id"
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
style={{ maxWidth: 72, minWidth: 72, width: 72 }}
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
sortable
></Column>
<Column
field="group"
header="Group"
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
hidden={compact}
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
sortable
></Column>
<Column
field="name"
@@ -220,6 +225,8 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
body={renderName}
style={{ maxWidth: nameColumnWidth }}
hidden={compact || medium}
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
sortable
></Column>
<Column
field="updated_at"
@@ -227,6 +234,8 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
dataType="date"
bodyClassName="w-[80px] text-ellipsis overflow-hidden whitespace-nowrap"
body={renderTimeLeft}
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
sortable
></Column>
</DataTable>
</>

View File

@@ -23,7 +23,7 @@ export default {
onError: handleError,
});
this.pushEvent('loaded');
this.pushEvent('ui_loaded');
},
handleEventWrapper(event: string, handler: (payload: any) => void) {

View File

@@ -43,7 +43,6 @@ defmodule WandererApp.Api.AccessList do
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
argument :owner_id_text_input, :string, allow_nil?: true
change manage_relationship(:owner_id, :owner, on_lookup: :relate, on_no_match: nil)
end
@@ -51,8 +50,6 @@ defmodule WandererApp.Api.AccessList do
update :update do
accept [:name, :description, :owner_id]
primary?(true)
argument :owner_id_text_input, :string, allow_nil?: true
end
update :assign_owner do

View File

@@ -63,7 +63,6 @@ defmodule WandererApp.Api.Map do
primary?(true)
argument :owner_id, :uuid, allow_nil?: false
argument :owner_id_text_input, :string, allow_nil?: true
argument :create_default_acl, :boolean, allow_nil?: true
argument :acls, {:array, :uuid}, allow_nil?: true
argument :acls_text_input, :string, allow_nil?: true

View File

@@ -18,10 +18,7 @@ defmodule WandererApp.Api.MapConnection do
action: :read
)
define(:by_locations,
get_by: [:map_id, :solar_system_source, :solar_system_target],
action: :read
)
define(:by_locations, action: :read_by_locations)
define(:read_by_map, action: :read_by_map)
define(:get_link_pairs_advanced, action: :get_link_pairs_advanced)
@@ -47,6 +44,13 @@ defmodule WandererApp.Api.MapConnection do
filter(expr(map_id == ^arg(:map_id)))
end
read :read_by_locations do
argument(:map_id, :string, allow_nil?: false)
argument(:solar_system_source, :integer, allow_nil?: false)
argument(:solar_system_target, :integer, allow_nil?: false)
filter(expr(map_id == ^arg(:map_id) and solar_system_source == ^arg(:solar_system_source) and solar_system_target == ^arg(:solar_system_target)))
end
read :get_link_pairs_advanced do
argument(:map_id, :string, allow_nil?: false)
argument(:include_mass_crit, :boolean, allow_nil?: false)

View File

@@ -68,13 +68,16 @@ defmodule WandererApp.Character.TrackerManager.Impl do
state
false ->
WandererApp.Character.update_character_state(character_id, %{opts: opts})
:telemetry.execute([:wanderer_app, :character, :tracker, :started], %{count: 1})
Logger.debug(fn -> "Start character tracker: #{inspect(character_id)}" end)
tracked_characters = [character_id | state.characters] |> Enum.uniq()
Task.start_link(fn ->
WandererApp.Character.update_character_state(character_id, %{opts: opts})
:telemetry.execute([:wanderer_app, :character, :tracker, :started], %{count: 1})
:ok
end)
tracked_characters = [character_id | state.characters] |> Enum.uniq()
WandererApp.Cache.insert("tracked_characters", tracked_characters)
%{state | characters: tracked_characters}

View File

@@ -229,7 +229,7 @@ defmodule WandererApp.EveDataService do
constellation_id = row["constellationID"] |> Integer.parse() |> elem(0)
{:ok, wormhole_class_id} =
_get_wormhole_class_id(
get_wormhole_class_id(
map_location_wormhole_classes,
region_id,
constellation_id,
@@ -237,16 +237,16 @@ defmodule WandererApp.EveDataService do
)
{:ok, constellation_name} =
_get_constellation_name(map_constellations, constellation_id)
get_constellation_name(map_constellations, constellation_id)
{:ok, region_name} = _get_region_name(map_regions, region_id)
{:ok, region_name} = get_region_name(map_regions, region_id)
{:ok, wormhole_class} = _get_wormhole_class(wormhole_classes, wormhole_class_id)
{:ok, wormhole_class} = get_wormhole_class(wormhole_classes, wormhole_class_id)
{:ok, security} = _get_security(row["security"])
{:ok, security} = get_security(row["security"])
{:ok, class_title} =
_get_class_title(
get_class_title(
wormhole_classes_info,
wormhole_class_id,
security,
@@ -270,7 +270,7 @@ defmodule WandererApp.EveDataService do
solar_system_id: solar_system_id,
solar_system_name: row["solarSystemName"],
solar_system_name_lc: row["solarSystemName"] |> String.downcase(),
sun_type_id: _get_sun_type_id(row["sunTypeID"]),
sun_type_id: get_sun_type_id(row["sunTypeID"]),
constellation_name: constellation_name,
region_name: region_name,
security: security,
@@ -279,8 +279,8 @@ defmodule WandererApp.EveDataService do
type_description: wormhole_class.title,
is_shattered: is_shattered
}
|> _get_wormhole_data(wormhole_systems, solar_system_id, wormhole_class)
|> _get_triglavian_data(triglavian_systems, solar_system_id)
|> get_wormhole_data(wormhole_systems, solar_system_id, wormhole_class)
|> get_triglavian_data(triglavian_systems, solar_system_id)
end
)
end
@@ -332,14 +332,14 @@ defmodule WandererApp.EveDataService do
)
end
defp _get_sun_type_id(sun_type_id) do
defp get_sun_type_id(sun_type_id) do
case sun_type_id do
"None" -> 0
_ -> sun_type_id |> Integer.parse() |> elem(0)
end
end
defp _get_wormhole_data(default_data, wormhole_systems, solar_system_id, wormhole_class) do
defp get_wormhole_data(default_data, wormhole_systems, solar_system_id, wormhole_class) do
case Enum.find(wormhole_systems, fn system -> system.solar_system_id == solar_system_id end) do
nil ->
default_data
@@ -355,7 +355,7 @@ defmodule WandererApp.EveDataService do
end
end
defp _get_triglavian_data(default_data, triglavian_systems, solar_system_id) do
defp get_triglavian_data(default_data, triglavian_systems, solar_system_id) do
case Enum.find(triglavian_systems, fn system -> system.solar_system_id == solar_system_id end) do
nil ->
default_data
@@ -370,14 +370,18 @@ defmodule WandererApp.EveDataService do
end
end
defp _get_security(security) do
defp get_security(security) do
case security do
nil -> {:ok, ""}
_ -> {:ok, Decimal.parse(security) |> elem(0) |> Decimal.round(1) |> Decimal.to_string()}
_ -> {:ok, String.to_float(security) |> get_true_security() |> Float.to_string(decimals: 1)}
end
end
defp _get_class_title(wormhole_classes_info, wormhole_class_id, security, wormhole_class) do
defp get_true_security(security) when is_float(security) and security > 0.0 and security < 0.05, do: security |> Float.ceil(1)
defp get_true_security(security) when is_float(security), do: security |> Float.floor(1)
defp get_class_title(wormhole_classes_info, wormhole_class_id, security, wormhole_class) do
case wormhole_class_id in [
wormhole_classes_info.names["hs"],
wormhole_classes_info.names["ls"],
@@ -391,7 +395,7 @@ defmodule WandererApp.EveDataService do
end
end
defp _get_constellation_name(constellations, constellation_id) do
defp get_constellation_name(constellations, constellation_id) do
case Enum.find(constellations, fn constellation ->
constellation.constellation_id == constellation_id
end) do
@@ -400,24 +404,24 @@ defmodule WandererApp.EveDataService do
end
end
defp _get_region_name(regions, region_id) do
defp get_region_name(regions, region_id) do
case Enum.find(regions, fn region -> region.region_id == region_id end) do
nil -> {:ok, ""}
region -> {:ok, region.region_name}
end
end
defp _get_wormhole_class(wormhole_classes, wormhole_class_id) do
defp get_wormhole_class(wormhole_classes, wormhole_class_id) do
{:ok,
Enum.find(wormhole_classes, fn wormhole_class ->
wormhole_class.wormhole_class_id == wormhole_class_id
end)}
end
defp _get_wormhole_class_id(_systems, _region_id, _constellation_id, 30_100_000),
defp get_wormhole_class_id(_systems, _region_id, _constellation_id, 30_100_000),
do: {:ok, 10_100}
defp _get_wormhole_class_id(systems, region_id, constellation_id, solar_system_id) do
defp get_wormhole_class_id(systems, region_id, constellation_id, solar_system_id) do
with region <-
Enum.find(systems, fn system ->
system.location_id |> Integer.parse() |> elem(0) == region_id
@@ -430,23 +434,23 @@ defmodule WandererApp.EveDataService do
Enum.find(systems, fn system ->
system.location_id |> Integer.parse() |> elem(0) == solar_system_id
end),
wormhole_class_id <- _get_wormhole_class_id(region, constellation, solar_system) do
wormhole_class_id <- get_wormhole_class_id(region, constellation, solar_system) do
{:ok, wormhole_class_id}
else
_ -> {:ok, -1}
end
end
defp _get_wormhole_class_id(_region, _constellation, solar_system)
defp get_wormhole_class_id(_region, _constellation, solar_system)
when not is_nil(solar_system),
do: solar_system.wormhole_class_id |> Integer.parse() |> elem(0)
defp _get_wormhole_class_id(_region, constellation, _solar_system)
defp get_wormhole_class_id(_region, constellation, _solar_system)
when not is_nil(constellation),
do: constellation.wormhole_class_id |> Integer.parse() |> elem(0)
defp _get_wormhole_class_id(region, _constellation, _solar_system) when not is_nil(region),
defp get_wormhole_class_id(region, _constellation, _solar_system) when not is_nil(region),
do: region.wormhole_class_id |> Integer.parse() |> elem(0)
defp _get_wormhole_class_id(_region, _constellation, _solar_system), do: -1
defp get_wormhole_class_id(_region, _constellation, _solar_system), do: -1
end

View File

@@ -10,8 +10,8 @@ defmodule WandererApp.Map.Manager do
alias WandererApp.Map.Server
alias WandererApp.Map.ServerSupervisor
@maps_start_per_second 100
@maps_start_interval 1500
@maps_start_per_second 5
@maps_start_interval 1000
@maps_queue :maps_queue
@garbage_collection_interval :timer.hours(1)
@check_maps_queue_interval :timer.seconds(1)

View File

@@ -177,37 +177,45 @@ defmodule WandererApp.Map.Server.Impl do
do: {:ok, map_id |> WandererApp.Map.list_characters()}
def add_character(%{map_id: map_id} = state, %{id: character_id} = character, track_character) do
with :ok <- map_id |> WandererApp.Map.add_character(character),
{:ok, _} <-
WandererApp.MapCharacterSettingsRepo.create(%{
character_id: character_id,
map_id: map_id,
tracked: track_character
}),
{:ok, character} <- WandererApp.Character.get_character(character_id) do
broadcast!(map_id, :character_added, character)
Task.start_link(fn ->
with :ok <- map_id |> WandererApp.Map.add_character(character),
{:ok, _} <-
WandererApp.MapCharacterSettingsRepo.create(%{
character_id: character_id,
map_id: map_id,
tracked: track_character
}),
{:ok, character} <- WandererApp.Character.get_character(character_id) do
broadcast!(map_id, :character_added, character)
:telemetry.execute([:wanderer_app, :map, :character, :added], %{count: 1})
:telemetry.execute([:wanderer_app, :map, :character, :added], %{count: 1})
state
else
{:error, _error} ->
state
end
:ok
else
{:error, _error} ->
:ok
end
end)
state
end
def remove_character(%{map_id: map_id} = state, character_id) do
with :ok <- WandererApp.Map.remove_character(map_id, character_id),
{:ok, character} <- WandererApp.Character.get_character(character_id) do
broadcast!(map_id, :character_removed, character)
Task.start_link(fn ->
with :ok <- WandererApp.Map.remove_character(map_id, character_id),
{:ok, character} <- WandererApp.Character.get_character(character_id) do
broadcast!(map_id, :character_removed, character)
:telemetry.execute([:wanderer_app, :map, :character, :removed], %{count: 1})
:telemetry.execute([:wanderer_app, :map, :character, :removed], %{count: 1})
state
else
{:error, _error} ->
state
end
:ok
else
{:error, _error} ->
:ok
end
end)
state
end
def untrack_characters(%{map_id: map_id} = state, characters_ids) do
@@ -357,17 +365,7 @@ defmodule WandererApp.Map.Server.Impl do
connections_to_remove
|> Enum.each(fn connection ->
@logger.debug(fn -> "Removing connection from map: #{inspect(connection)}" end)
connection
|> WandererApp.MapConnectionRepo.destroy!()
|> case do
:ok ->
:ok
{:error, error} ->
@logger.error("Failed to remove connection from map: #{inspect(error, pretty: true)}")
:ok
end
WandererApp.MapConnectionRepo.destroy(map_id, connection)
end)
@ddrt.delete(removed_ids, rtree_name)
@@ -1567,8 +1565,7 @@ defmodule WandererApp.Map.Server.Impl do
old_location.solar_system_id
) do
{:ok, connection} ->
connection
|> WandererApp.MapConnectionRepo.destroy!()
:ok = WandererApp.MapConnectionRepo.destroy(map_id, connection)
broadcast!(map_id, :remove_connections, [connection])
map_id |> WandererApp.Map.remove_connection(connection)

View File

@@ -1,12 +1,60 @@
defmodule WandererApp.MapConnectionRepo do
use WandererApp, :repository
require Logger
@logger Application.compile_env(:wanderer_app, :logger)
def get_by_map(map_id),
do: WandererApp.Api.MapConnection.read_by_map(%{map_id: map_id})
def get_by_locations(map_id, solar_system_source, solar_system_target) do
WandererApp.Api.MapConnection.by_locations(%{map_id: map_id, solar_system_source: solar_system_source, solar_system_target: solar_system_target})
|> case do
{:ok, connections} ->
{:ok, connections}
{:error, %Ash.Error.Query.NotFound{}} ->
{:ok, []}
{:error, error} ->
@logger.error("Failed to get connections: #{inspect(error, pretty: true)}")
{:error, error}
end
end
def create!(connection), do: connection |> WandererApp.Api.MapConnection.create!()
def destroy!(connection), do: connection |> WandererApp.Api.MapConnection.destroy!()
def destroy(map_id, connection) do
{:ok, from_connections} = get_by_locations(map_id, connection.solar_system_source, connection.solar_system_target)
{:ok, to_connections} = get_by_locations(map_id, connection.solar_system_target, connection.solar_system_source)
[from_connections ++ to_connections]
|> List.flatten()
|> bulk_destroy!()
|> case do
:ok ->
:ok
error ->
@logger.error("Failed to remove connections from map: #{inspect(error, pretty: true)}")
:ok
end
end
def destroy!(connection), do:
connection |> WandererApp.Api.MapConnection.destroy!()
def bulk_destroy!(connections) do
connections
|> WandererApp.Api.MapConnection.destroy!()
|> case do
%Ash.BulkResult{status: :success} ->
:ok
error ->
error
end
end
def update_time_status(connection, update),
do:

View File

@@ -602,11 +602,11 @@ defmodule WandererAppWeb.CoreComponents do
<tr
:for={row <- @rows}
id={@row_id && @row_id.(row)}
phx-click={@row_click && @row_click.(row)}
class={"hover #{if @row_selected && @row_selected.(row), do: "!bg-slate-600", else: ""} #{if @row_click, do: "cursor-pointer", else: ""}"}
>
<td
:for={{col, _index} <- Enum.with_index(@col)}
phx-click={@row_click && @row_click.(row)}
>
<%= render_slot(col, @row_item.(row)) %>
</td>

View File

@@ -99,40 +99,34 @@ defmodule WandererAppWeb.AccessListsLive do
end
defp apply_action(socket, :add_members, %{"id" => acl_id} = _params) do
{:ok, %{owner: %{id: _character_id}} = access_list} =
socket.assigns.access_lists |> Enum.find(&(&1.id == acl_id)) |> Ash.load(:owner)
with {:ok, %{owner: %{id: _character_id}} = access_list} <- socket.assigns.access_lists |> Enum.find(&(&1.id == acl_id)) |> Ash.load(:owner),
user_character_ids <- socket.assigns.current_user.characters |> Enum.map(& &1.id) do
user_character_ids
|> Enum.each(fn user_character_id ->
:ok = WandererApp.Character.TrackerManager.start_tracking(user_character_id)
end)
user_character_ids = socket.assigns.current_user.characters |> Enum.map(& &1.id)
user_character_ids
|> Enum.each(fn user_character_id ->
:ok = WandererApp.Character.TrackerManager.start_tracking(user_character_id)
end)
socket
|> assign(:active_page, :access_lists)
|> assign(:page_title, "Access Lists - Add Members")
|> assign(:selected_acl_id, acl_id)
|> assign(:user_character_ids, user_character_ids)
|> assign(
member_search_options: socket.assigns.characters |> Enum.map(&map_user_character_info/1)
)
|> assign(:access_list, access_list)
|> assign(
:members,
WandererApp.Api.AccessListMember.read_by_access_list!(%{access_list_id: acl_id})
)
|> assign(
:member_form,
%{} |> to_form()
)
end
@impl true
def handle_event("set-default", %{"id" => id}, socket) do
send_update(LiveSelect.Component, options: socket.assigns.characters, id: id)
{:noreply, socket}
socket
|> assign(:active_page, :access_lists)
|> assign(:page_title, "Access Lists - Add Members")
|> assign(:selected_acl_id, acl_id)
|> assign(:user_character_ids, user_character_ids)
|> assign(
member_search_options: socket.assigns.characters |> Enum.map(&map_user_character_info/1)
)
|> assign(:access_list, access_list)
|> assign(
:members,
WandererApp.Api.AccessListMember.read_by_access_list!(%{access_list_id: acl_id})
)
|> assign(
:member_form,
%{} |> to_form()
)
else
_ ->
socket
end
end
@impl true

View File

@@ -127,23 +127,13 @@
<.form :let={f} for={@form} phx-change="validate" phx-submit={@live_action}>
<.input type="text" field={f[:name]} placeholder="Name" />
<.input type="textarea" field={f[:description]} placeholder="Public description" />
<.live_select
<.input
type="select"
field={f[:owner_id]}
dropdown_extra_class="max-h-64"
available_option_class="w-full"
value_mapper={&map_character/1}
update_min_len={0}
phx-focus="set-default"
options={@characters}
placeholder="Owner"
>
<:option :let={option}>
<div class="flex items-center">
<.avatar url={member_icon_url(option.eve_id)} label={option.label} />
&nbsp;<%= option.label %>
</div>
</:option>
</.live_select>
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map owner"
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<div class="modal-action">
<.button class="mt-2" type="submit" phx-disable-with="Saving...">
<%= (@live_action == :create && "Create") || "Save" %>

View File

@@ -45,7 +45,7 @@ defmodule WandererAppWeb.MapLive do
deleted: false
} = map} ->
Process.send_after(self(), {:init_map, map}, 100)
Process.send_after(self(), {:init_map, map}, 10)
socket
|> assign(
@@ -114,7 +114,7 @@ defmodule WandererAppWeb.MapLive do
}
} = socket
) do
Task.async(fn -> _on_map_started(map_id, current_user, user_permissions) end)
_on_map_started(map_id, current_user, user_permissions)
{:noreply, socket}
end
@@ -386,17 +386,17 @@ defmodule WandererAppWeb.MapLive do
page_title: map_name,
user_permissions: user_permissions,
tracked_character_ids: tracked_character_ids
}}, 100)
}}, 10)
only_tracked_characters and can_track? and not all_character_tracked? ->
Process.send_after(self(), :not_all_characters_tracked, 100)
Process.send_after(self(), :not_all_characters_tracked, 10)
true ->
Process.send_after(self(), :no_permissions, 100)
Process.send_after(self(), :no_permissions, 10)
end
else
_ ->
Process.send_after(self(), :no_access, 100)
Process.send_after(self(), :no_access, 10)
end
{:noreply, socket}
@@ -404,13 +404,6 @@ defmodule WandererAppWeb.MapLive do
def handle_info({:map_init, %{map_id: map_id} = initial_data}, socket) do
Phoenix.PubSub.subscribe(WandererApp.PubSub, map_id)
WandererApp.Map.Manager.start_map(map_id)
{:ok, map_started} = WandererApp.Cache.lookup("map_#{map_id}:started", false)
if map_started do
Process.send_after(self(), %{event: :map_started}, 100)
end
{:noreply,
socket
@@ -464,7 +457,7 @@ defmodule WandererAppWeb.MapLive do
map_id: map_id,
user_characters: user_character_eve_ids,
initial_data: initial_data
}}, 100)
}}, 10)
{:noreply, socket}
end
@@ -567,7 +560,15 @@ defmodule WandererAppWeb.MapLive do
def handle_info(_event, socket), do: {:noreply, socket}
@impl true
def handle_event("loaded", _body, socket) do
def handle_event("ui_loaded", _body, %{assigns: %{map_id: map_id}} = socket) do
{:ok, map_started} = WandererApp.Cache.lookup("map_#{map_id}:started", false)
if map_started do
Process.send_after(self(), %{event: :map_started}, 10)
else
WandererApp.Map.Manager.start_map(map_id)
end
{:noreply, socket}
end
@@ -577,7 +578,8 @@ defmodule WandererAppWeb.MapLive do
end
@impl true
def handle_event("change_map", %{"map_slug" => map_slug} = _event, socket) do
def handle_event("change_map", %{"map_slug" => map_slug} = _event, %{assigns: %{map_id: map_id}} = socket) do
Phoenix.PubSub.unsubscribe(WandererApp.PubSub, map_id)
{:noreply, push_navigate(socket, to: ~p"/#{map_slug}")}
end
@@ -1564,16 +1566,23 @@ defmodule WandererAppWeb.MapLive do
)
|> Map.put(:reset, true)
{:map_started_data,
%{
map_id: map_id,
user_characters: user_character_eve_ids,
initial_data: initial_data,
events: events
}}
Process.send_after(self(), {:map_start, %{
map_id: map_id,
user_characters: user_character_eve_ids,
initial_data: initial_data,
events: events
}}, 10)
# {:map_started_data,
# %{
# map_id: map_id,
# user_characters: user_character_eve_ids,
# initial_data: initial_data,
# events: events
# }}
_ ->
{:map_error, :no_access}
Process.send_after(self(), {:map_error, :no_access}, 10)
end
end
@@ -2079,13 +2088,14 @@ defmodule WandererAppWeb.MapLive do
:ok = WandererApp.Character.TrackerManager.start_tracking(character_id)
end
defp _push_map_event(socket, type, event_body),
do:
defp _push_map_event(socket, type, event_body)
do
socket
|> push_event("map_event", %{
type: type,
body: event_body |> WandererApp.Utils.JSONUtil.compress()
})
end
defp map_id(%{assigns: %{map_id: map_id}} = _socket), do: map_id
end

View File

@@ -2,9 +2,10 @@
id="map-loader"
data-loading={show_loader("map-loader")}
data-loaded={hide_loader("map-loader")}
class="!z-100 absolute w-screen h-screen bg-transparent hidden"
class="!z-100 w-screen h-screen hidden relative"
>
<div class="flex w-full h-full items-center justify-center">
<div class="hs-overlay-backdrop transition duration absolute inset-0 blur" />
<div class="flex !z-[150] w-full h-full items-center justify-center">
<div class="Loader" data-text="Wanderer">
<span class="Loader__Circle"></span>
<span class="Loader__Circle"></span>
@@ -12,6 +13,8 @@
<span class="Loader__Circle"></span>
</div>
</div>
</div>
<div class="w-full h-full" id="mapper" phx-hook="Mapper" phx-update="ignore"></div>

View File

@@ -167,24 +167,6 @@ defmodule WandererAppWeb.MapsLive do
{:noreply, socket}
end
@impl true
def handle_event(
"live_select_change",
%{"id" => "form_owner_id_live_select_component" = id, "text" => text} = _change_event,
socket
) do
options =
if text == "" do
socket.assigns.characters
else
socket.assigns.characters
end
send_update(LiveSelect.Component, options: options, id: id)
{:noreply, socket}
end
@impl true
def handle_event(
"live_select_change",

View File

@@ -137,23 +137,17 @@
<.input type="text" field={f[:name]} placeholder="Name" />
<.input type="text" field={f[:slug]} prefix={@uri} placeholder="map-slug" />
<.input type="textarea" field={f[:description]} placeholder="Public description" />
<.live_select
<.input
type="select"
field={f[:owner_id]}
value_mapper={&map_character/1}
options={@characters}
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map owner"
>
<:option :let={option}>
<div class="flex items-center">
<.avatar url={member_icon_url(option.eve_id)} label={option.label} />
&nbsp;<%= option.label %>
</div>
</:option>
</.live_select>
options={Enum.map(@characters, fn character -> {character.label, character.id} end)}
/>
<.input
type="select"
field={f[:scope]}
class="p-dropdown p-component p-inputwrapper"
class="p-dropdown p-component p-inputwrapper mt-8"
placeholder="Select a map scope"
options={Enum.map(@scopes, fn scope -> {scope, scope} end)}
/>

View File

@@ -2,7 +2,7 @@ defmodule WandererApp.MixProject do
use Mix.Project
@source_url "https://github.com/wanderer-industries/wanderer"
@version "1.2.0"
@version "1.2.8"
def project do
[