mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-11-25 10:34:42 +00:00
Compare commits
18 Commits
v1.2.8
...
19-add-map
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d622e486f4 | ||
|
|
81926633b0 | ||
|
|
e66c125dbf | ||
|
|
e4fe8fdc53 | ||
|
|
9862bcfa05 | ||
|
|
0ac5451bef | ||
|
|
669479b815 | ||
|
|
2721130566 | ||
|
|
6e33ad943f | ||
|
|
f4b7357802 | ||
|
|
7a404a7e6a | ||
|
|
5158700a79 | ||
|
|
41d10c1b47 | ||
|
|
3aaac91f07 | ||
|
|
ea7ff080b8 | ||
|
|
b5270958eb | ||
|
|
b0a38eab8c | ||
|
|
0a478e82ba |
23
CHANGELOG.md
23
CHANGELOG.md
@@ -2,6 +2,29 @@
|
||||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v1.3.0](https://github.com/wanderer-industries/wanderer/compare/v1.2.10...v1.3.0) (2024-10-07)
|
||||
|
||||
|
||||
|
||||
|
||||
### Features:
|
||||
|
||||
* Map: Fix default sort
|
||||
|
||||
* Map: Remove resizible and fix styles of column sorting
|
||||
|
||||
* Map: Revision of sorting from also adding ability to sort all columns
|
||||
|
||||
## [v1.2.10](https://github.com/wanderer-industries/wanderer/compare/v1.2.9...v1.2.10) (2024-10-07)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.2.9](https://github.com/wanderer-industries/wanderer/compare/v1.2.8...v1.2.9) (2024-10-07)
|
||||
|
||||
|
||||
|
||||
|
||||
## [v1.2.8](https://github.com/wanderer-industries/wanderer/compare/v1.2.7...v1.2.8) (2024-10-06)
|
||||
|
||||
|
||||
|
||||
@@ -67,3 +67,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.p-sortable-column {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
padding: 3px 4px;
|
||||
}
|
||||
|
||||
.p-selectable-row td {
|
||||
padding: 4px 4px;
|
||||
}
|
||||
|
||||
.p-sortable-column > .p-column-header-content > span:last-child {
|
||||
transform: scale(0.7);
|
||||
|
||||
& > svg {
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,3 +4,7 @@
|
||||
font-size: 12px !important;
|
||||
line-height: 8px;
|
||||
}
|
||||
|
||||
.Table {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { parseSignatures } from '@/hooks/Mapper/helpers';
|
||||
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
|
||||
import { WdTooltip, WdTooltipHandlers } from '@/hooks/Mapper/components/ui-kit';
|
||||
|
||||
import { DataTable, DataTableRowMouseEvent } from 'primereact/datatable';
|
||||
import { DataTable, DataTableRowMouseEvent, SortOrder } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import useRefState from 'react-usestateref';
|
||||
@@ -25,6 +25,18 @@ import {
|
||||
renderName,
|
||||
renderTimeLeft,
|
||||
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders';
|
||||
// import { PrimeIcons } from 'primereact/api';
|
||||
import useLocalStorageState from 'use-local-storage-state';
|
||||
|
||||
type SystemSignaturesSortSettings = {
|
||||
sortField: string;
|
||||
sortOrder: SortOrder;
|
||||
};
|
||||
|
||||
const SORT_DEFAULT_VALUES: SystemSignaturesSortSettings = {
|
||||
sortField: 'updated_at',
|
||||
sortOrder: -1,
|
||||
};
|
||||
|
||||
interface SystemSignaturesContentProps {
|
||||
systemId: string;
|
||||
@@ -39,6 +51,10 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
|
||||
const [hoveredSig, setHoveredSig] = useState<SystemSignature | null>(null);
|
||||
|
||||
const [sortSettings, setSortSettings] = useLocalStorageState<SystemSignaturesSortSettings>('window:signatures:sort', {
|
||||
defaultValue: SORT_DEFAULT_VALUES,
|
||||
});
|
||||
|
||||
const tableRef = useRef<HTMLDivElement>(null);
|
||||
const compact = useMaxWidth(tableRef, 260);
|
||||
const medium = useMaxWidth(tableRef, 380);
|
||||
@@ -50,7 +66,7 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
const handleResize = useCallback(() => {
|
||||
if (tableRef.current) {
|
||||
const tableWidth = tableRef.current.offsetWidth;
|
||||
const otherColumnsWidth = 265;
|
||||
const otherColumnsWidth = 276;
|
||||
const availableWidth = tableWidth - otherColumnsWidth;
|
||||
setNameColumnWidth(`${availableWidth}px`);
|
||||
}
|
||||
@@ -159,6 +175,14 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
setHoveredSig(null);
|
||||
}, []);
|
||||
|
||||
// const renderToolbar = (/*row: SystemSignature*/) => {
|
||||
// return (
|
||||
// <div className="flex justify-end items-center gap-2">
|
||||
// <span className={clsx(PrimeIcons.PENCIL, 'text-[10px]')}></span>
|
||||
// </div>
|
||||
// );
|
||||
// };
|
||||
|
||||
return (
|
||||
<div ref={tableRef} className="h-full">
|
||||
{filteredSignatures.length === 0 ? (
|
||||
@@ -168,19 +192,23 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
) : (
|
||||
<>
|
||||
<DataTable
|
||||
className={classes.Table}
|
||||
value={filteredSignatures}
|
||||
size="small"
|
||||
selectionMode="multiple"
|
||||
selection={selectedSignatures}
|
||||
metaKeySelection
|
||||
onSelectionChange={e => setSelectedSignatures(e.value)}
|
||||
dataKey="eve_id"
|
||||
tableClassName="w-full select-none"
|
||||
resizableColumns
|
||||
resizableColumns={false}
|
||||
rowHover
|
||||
selectAll
|
||||
sortField="eve_id"
|
||||
onRowMouseEnter={handleEnterRow}
|
||||
onRowMouseLeave={handleLeaveRow}
|
||||
sortField={sortSettings.sortField}
|
||||
sortOrder={sortSettings.sortOrder}
|
||||
onSort={event => setSortSettings(() => ({ sortField: event.sortField, sortOrder: event.sortOrder }))}
|
||||
onRowMouseEnter={compact || medium ? handleEnterRow : undefined}
|
||||
onRowMouseLeave={compact || medium ? handleLeaveRow : undefined}
|
||||
rowClassName={row => {
|
||||
if (selectedSignatures.some(x => x.eve_id === row.eve_id)) {
|
||||
return clsx(classes.TableRowCompact, 'bg-amber-500/50 hover:bg-amber-500/70 transition duration-200');
|
||||
@@ -198,8 +226,7 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
bodyClassName="p-0 px-1"
|
||||
field="group"
|
||||
body={renderIcon}
|
||||
style={{ maxWidth: 26, minWidth: 26, width: 26 }}
|
||||
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
|
||||
style={{ maxWidth: 26, minWidth: 26, width: 26, height: 25 }}
|
||||
></Column>
|
||||
|
||||
<Column
|
||||
@@ -207,7 +234,6 @@ 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
|
||||
@@ -215,7 +241,6 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
header="Group"
|
||||
bodyClassName="text-ellipsis overflow-hidden whitespace-nowrap"
|
||||
hidden={compact}
|
||||
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
|
||||
sortable
|
||||
></Column>
|
||||
<Column
|
||||
@@ -225,7 +250,6 @@ export const SystemSignaturesContent = ({ systemId, settings }: SystemSignatures
|
||||
body={renderName}
|
||||
style={{ maxWidth: nameColumnWidth }}
|
||||
hidden={compact || medium}
|
||||
headerStyle={{ fontSize: "14px", padding: "0.25rem" }}
|
||||
sortable
|
||||
></Column>
|
||||
<Column
|
||||
@@ -234,9 +258,16 @@ 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>
|
||||
|
||||
{/*<Column*/}
|
||||
{/* bodyClassName="p-0 pl-1 pr-2"*/}
|
||||
{/* field="group"*/}
|
||||
{/* body={renderToolbar}*/}
|
||||
{/* headerClassName={headerClasses}*/}
|
||||
{/* style={{ maxWidth: 26, minWidth: 26, width: 26 }}*/}
|
||||
{/*></Column>*/}
|
||||
</DataTable>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { TimeLeft } from '@/hooks/Mapper/components/ui-kit';
|
||||
|
||||
export const renderTimeLeft = (row: SystemSignature) => {
|
||||
return (
|
||||
<div className="flex justify-end w-full items-center">
|
||||
<div className="flex w-full items-center">
|
||||
<TimeLeft cDate={row.updated_at ? new Date(row.updated_at) : undefined} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -60,15 +60,7 @@ config :dart_sass, :version, "1.54.5"
|
||||
|
||||
config :tailwind, :version, "3.2.7"
|
||||
|
||||
config :wanderer_app, WandererApp.PromEx,
|
||||
manual_metrics_start_delay: :no_delay,
|
||||
metrics_server: [
|
||||
port: 4021,
|
||||
path: "/metrics",
|
||||
protocol: :http,
|
||||
pool_size: 5,
|
||||
cowboy_opts: [ip: {0, 0, 0, 0}]
|
||||
]
|
||||
config :wanderer_app, WandererApp.PromEx, manual_metrics_start_delay: :no_delay
|
||||
|
||||
config :wanderer_app,
|
||||
grafana_datasource_id: "wanderer"
|
||||
|
||||
@@ -192,9 +192,20 @@ if config_env() == :prod do
|
||||
|> get_var_from_path_or_env("DATABASE_SSL_ENABLED", "false")
|
||||
|> String.to_existing_atom()
|
||||
|
||||
db_ssl_verify_none =
|
||||
config_dir
|
||||
|> get_var_from_path_or_env("DATABASE_SSL_VERIFY_NONE", "false")
|
||||
|> String.to_existing_atom()
|
||||
|
||||
client_opts =
|
||||
if db_ssl_verify_none do
|
||||
[verify: :verify_none]
|
||||
end
|
||||
|
||||
config :wanderer_app, WandererApp.Repo,
|
||||
url: database_url,
|
||||
ssl: db_ssl_enabled,
|
||||
ssl_opts: client_opts,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||
socket_options: maybe_ipv6
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ defmodule WandererApp.Api.Map do
|
||||
define(:update, action: :update)
|
||||
define(:update_acls, action: :update_acls)
|
||||
define(:update_hubs, action: :update_hubs)
|
||||
define(:update_options, action: :update_options)
|
||||
define(:assign_owner, action: :assign_owner)
|
||||
define(:mark_as_deleted, action: :mark_as_deleted)
|
||||
|
||||
@@ -112,6 +113,10 @@ defmodule WandererApp.Api.Map do
|
||||
accept [:hubs]
|
||||
end
|
||||
|
||||
update :update_options do
|
||||
accept [:options]
|
||||
end
|
||||
|
||||
update :mark_as_deleted do
|
||||
accept([])
|
||||
|
||||
@@ -167,6 +172,10 @@ defmodule WandererApp.Api.Map do
|
||||
allow_nil?(true)
|
||||
end
|
||||
|
||||
attribute :options, :string do
|
||||
allow_nil? true
|
||||
end
|
||||
|
||||
create_timestamp(:inserted_at)
|
||||
update_timestamp(:updated_at)
|
||||
end
|
||||
|
||||
@@ -52,6 +52,15 @@ defmodule WandererApp.Map do
|
||||
end
|
||||
end
|
||||
|
||||
def get_map_options!(map) do
|
||||
map
|
||||
|> Map.get(:options)
|
||||
|> case do
|
||||
nil -> %{"layout" => "left_to_right"}
|
||||
options -> Jason.decode!(options)
|
||||
end
|
||||
end
|
||||
|
||||
def update_map(map_id, map_update) do
|
||||
Cachex.get_and_update(:map_cache, map_id, fn map ->
|
||||
case map do
|
||||
|
||||
@@ -19,46 +19,47 @@ defmodule WandererApp.Map.PositionCalculator do
|
||||
|
||||
def get_system_bounding_rect(_system), do: [{0, 0}, {0, 0}]
|
||||
|
||||
def get_new_system_position(nil, rtree_name) do
|
||||
{:ok, {x, y}} = rtree_name |> _check_system_available_positions(@start_x, @start_y, 1)
|
||||
def get_new_system_position(nil, rtree_name, opts) do
|
||||
{:ok, {x, y}} = rtree_name |> check_system_available_positions(@start_x, @start_y, 1, opts)
|
||||
%{x: x, y: y}
|
||||
end
|
||||
|
||||
def get_new_system_position(
|
||||
%{position_x: start_x, position_y: start_y} = _old_system,
|
||||
rtree_name
|
||||
rtree_name,
|
||||
opts
|
||||
) do
|
||||
{:ok, {x, y}} = rtree_name |> _check_system_available_positions(start_x, start_y, 1)
|
||||
{:ok, {x, y}} = rtree_name |> check_system_available_positions(start_x, start_y, 1, opts)
|
||||
|
||||
%{x: x, y: y}
|
||||
end
|
||||
|
||||
defp _check_system_available_positions(_rtree_name, _start_x, _start_y, 100) do
|
||||
{:ok, {@start_x, @start_y}}
|
||||
end
|
||||
defp check_system_available_positions(_rtree_name, _start_x, _start_y, 100, _opts),
|
||||
do: {:ok, {@start_x, @start_y}}
|
||||
|
||||
defp _check_system_available_positions(rtree_name, start_x, start_y, level) do
|
||||
possible_positions = _get_available_positions(level, start_x, start_y)
|
||||
defp check_system_available_positions(rtree_name, start_x, start_y, level, opts) do
|
||||
possible_positions = get_available_positions(level, start_x, start_y, opts)
|
||||
|
||||
case _get_available_position(possible_positions, rtree_name) do
|
||||
case get_available_position(possible_positions, rtree_name) do
|
||||
{:ok, nil} ->
|
||||
rtree_name |> _check_system_available_positions(start_x, start_y, level + 1)
|
||||
rtree_name |> check_system_available_positions(start_x, start_y, level + 1, opts)
|
||||
|
||||
{:ok, position} ->
|
||||
{:ok, position}
|
||||
end
|
||||
end
|
||||
|
||||
defp _get_available_position([], _rtree_name), do: {:ok, nil}
|
||||
defp get_available_position([], _rtree_name), do: {:ok, nil}
|
||||
|
||||
defp _get_available_position([position | rest], rtree_name) do
|
||||
if _is_available_position(position, rtree_name) do
|
||||
defp get_available_position([position | rest], rtree_name) do
|
||||
if is_available_position(position, rtree_name) do
|
||||
{:ok, position}
|
||||
else
|
||||
_get_available_position(rest, rtree_name)
|
||||
get_available_position(rest, rtree_name)
|
||||
end
|
||||
end
|
||||
|
||||
defp _is_available_position({x, y} = _position, rtree_name) do
|
||||
defp is_available_position({x, y} = _position, rtree_name) do
|
||||
case DDRT.query(get_system_bounding_rect(%{position_x: x, position_y: y}), rtree_name) do
|
||||
{:ok, []} ->
|
||||
true
|
||||
@@ -71,9 +72,10 @@ defmodule WandererApp.Map.PositionCalculator do
|
||||
end
|
||||
end
|
||||
|
||||
def _get_available_positions(level, x, y), do: _adjusted_coordinates(1 + level * 2, x, y)
|
||||
def get_available_positions(level, x, y, opts),
|
||||
do: adjusted_coordinates(1 + level * 2, x, y, opts)
|
||||
|
||||
defp _edge_coordinates(n) when n > 1 do
|
||||
defp edge_coordinates(n, opts) when n > 1 do
|
||||
min = -div(n, 2)
|
||||
max = div(n, 2)
|
||||
# Top edge
|
||||
@@ -90,16 +92,20 @@ defmodule WandererApp.Map.PositionCalculator do
|
||||
|> Enum.uniq()
|
||||
end
|
||||
|
||||
defp _sorted_edge_coordinates(n) when n > 1 do
|
||||
coordinates = _edge_coordinates(n)
|
||||
middle_right_index = div(n, 2)
|
||||
defp sorted_edge_coordinates(n, opts) when n > 1 do
|
||||
coordinates = edge_coordinates(n, opts)
|
||||
start_index = get_start_index(n, opts[:layout])
|
||||
|
||||
Enum.slice(coordinates, middle_right_index, length(coordinates) - middle_right_index) ++
|
||||
Enum.slice(coordinates, 0, middle_right_index)
|
||||
Enum.slice(coordinates, start_index, length(coordinates) - start_index) ++
|
||||
Enum.slice(coordinates, 0, start_index)
|
||||
end
|
||||
|
||||
defp _adjusted_coordinates(n, start_x, start_y) when n > 1 do
|
||||
sorted_coords = _sorted_edge_coordinates(n)
|
||||
defp get_start_index(n, "left_to_right"), do: div(n, 2)
|
||||
|
||||
defp get_start_index(n, "top_to_bottom"), do: div(n, 2) + n - 1
|
||||
|
||||
defp adjusted_coordinates(n, start_x, start_y, opts) when n > 1 do
|
||||
sorted_coords = sorted_edge_coordinates(n, opts)
|
||||
|
||||
Enum.map(sorted_coords, fn {x, y} ->
|
||||
{
|
||||
|
||||
@@ -11,7 +11,8 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
defstruct [
|
||||
:map_id,
|
||||
:rtree_name,
|
||||
map: nil
|
||||
map: nil,
|
||||
map_opts: []
|
||||
]
|
||||
|
||||
# @ccp1 -1
|
||||
@@ -795,6 +796,9 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
}
|
||||
end
|
||||
|
||||
def handle_event({:options_updated, options}, %{map: map, map_id: map_id} = state),
|
||||
do: %{state | map_opts: [layout: options.layout]}
|
||||
|
||||
def handle_event({ref, _result}, %{map_id: _map_id} = state) do
|
||||
Process.demonitor(ref, [:flush])
|
||||
|
||||
@@ -834,12 +838,12 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
character_id,
|
||||
location,
|
||||
old_location,
|
||||
%{map: map, map_id: map_id, rtree_name: rtree_name} = _state
|
||||
%{map: map, map_id: map_id, rtree_name: rtree_name, map_opts: map_opts} = _state
|
||||
) do
|
||||
case is_nil(old_location.solar_system_id) and
|
||||
_can_add_location(map.scope, location.solar_system_id) do
|
||||
true ->
|
||||
:ok = maybe_add_system(map_id, location, nil, rtree_name)
|
||||
:ok = maybe_add_system(map_id, location, nil, rtree_name, map_opts)
|
||||
|
||||
_ ->
|
||||
case _is_connection_valid(
|
||||
@@ -849,8 +853,8 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
) do
|
||||
true ->
|
||||
{:ok, character} = WandererApp.Character.get_character(character_id)
|
||||
:ok = maybe_add_system(map_id, location, old_location, rtree_name)
|
||||
:ok = maybe_add_system(map_id, old_location, location, rtree_name)
|
||||
:ok = maybe_add_system(map_id, location, old_location, rtree_name, map_opts)
|
||||
:ok = maybe_add_system(map_id, old_location, location, rtree_name, map_opts)
|
||||
:ok = maybe_add_connection(map_id, location, old_location, character)
|
||||
|
||||
_ ->
|
||||
@@ -1097,7 +1101,7 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
end)}
|
||||
|
||||
defp _add_system(
|
||||
%{map_id: map_id, rtree_name: rtree_name} = state,
|
||||
%{map_id: map_id, map_opts: map_opts, rtree_name: rtree_name} = state,
|
||||
%{
|
||||
solar_system_id: solar_system_id,
|
||||
coordinates: coordinates
|
||||
@@ -1113,7 +1117,7 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
|
||||
_ ->
|
||||
%{x: x, y: y} =
|
||||
WandererApp.Map.PositionCalculator.get_new_system_position(nil, rtree_name)
|
||||
WandererApp.Map.PositionCalculator.get_new_system_position(nil, rtree_name, map_opts)
|
||||
|
||||
%{"x" => x, "y" => y}
|
||||
end
|
||||
@@ -1255,20 +1259,22 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
|
||||
defp _init_map(
|
||||
state,
|
||||
%{characters: characters} = map,
|
||||
%{characters: characters} = initial_map,
|
||||
subscription_settings,
|
||||
systems,
|
||||
connections
|
||||
) do
|
||||
map =
|
||||
map
|
||||
initial_map
|
||||
|> WandererApp.Map.new()
|
||||
|> WandererApp.Map.update_subscription_settings!(subscription_settings)
|
||||
|> WandererApp.Map.add_systems!(systems)
|
||||
|> WandererApp.Map.add_connections!(connections)
|
||||
|> WandererApp.Map.add_characters!(characters)
|
||||
|
||||
%{state | map: map}
|
||||
map_options = WandererApp.Map.get_map_options!(initial_map)
|
||||
|
||||
%{state | map: map, map_opts: [layout: map_options |> Map.get("layout")]}
|
||||
end
|
||||
|
||||
defp _init_map_systems(state, [] = _systems), do: state
|
||||
@@ -1614,11 +1620,11 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
|
||||
defp maybe_add_connection(_map_id, _location, _old_location, _character), do: :ok
|
||||
|
||||
defp maybe_add_system(map_id, location, old_location, rtree_name)
|
||||
defp maybe_add_system(map_id, location, old_location, rtree_name, opts)
|
||||
when not is_nil(location) do
|
||||
case WandererApp.Map.check_location(map_id, location) do
|
||||
{:ok, location} ->
|
||||
{:ok, position} = calc_new_system_position(map_id, old_location, rtree_name)
|
||||
{:ok, position} = calc_new_system_position(map_id, old_location, rtree_name, opts)
|
||||
|
||||
case WandererApp.MapSystemRepo.get_by_map_and_solar_system_id(
|
||||
map_id,
|
||||
@@ -1688,14 +1694,14 @@ defmodule WandererApp.Map.Server.Impl do
|
||||
end
|
||||
end
|
||||
|
||||
defp maybe_add_system(_map_id, _location, _old_location, _rtree_name), do: :ok
|
||||
defp maybe_add_system(_map_id, _location, _old_location, _rtree_name, _opts), do: :ok
|
||||
|
||||
defp calc_new_system_position(map_id, old_location, rtree_name) do
|
||||
defp calc_new_system_position(map_id, old_location, rtree_name, opts),
|
||||
do:
|
||||
{:ok,
|
||||
map_id
|
||||
|> WandererApp.Map.find_system_by_location(old_location)
|
||||
|> WandererApp.Map.PositionCalculator.get_new_system_position(rtree_name)}
|
||||
end
|
||||
|> WandererApp.Map.PositionCalculator.get_new_system_position(rtree_name, opts)}
|
||||
|
||||
defp _broadcast_acl_updates(
|
||||
{:ok,
|
||||
|
||||
@@ -68,7 +68,7 @@ defmodule WandererAppWeb.MapLive do
|
||||
{:ok,
|
||||
%{
|
||||
deleted: true
|
||||
} = map} ->
|
||||
} = _map} ->
|
||||
socket
|
||||
|> put_flash(
|
||||
:error,
|
||||
@@ -511,7 +511,7 @@ defmodule WandererAppWeb.MapLive do
|
||||
def handle_info(
|
||||
{ref, result},
|
||||
socket
|
||||
) do
|
||||
) when is_reference(ref) do
|
||||
Process.demonitor(ref, [:flush])
|
||||
|
||||
case result do
|
||||
@@ -554,8 +554,6 @@ defmodule WandererAppWeb.MapLive do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@impl true
|
||||
def handle_info(_event, socket), do: {:noreply, socket}
|
||||
|
||||
@@ -1572,16 +1570,9 @@ defmodule WandererAppWeb.MapLive do
|
||||
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
|
||||
# }}
|
||||
|
||||
_ ->
|
||||
Process.send_after(self(), {:map_error, :no_access}, 10)
|
||||
Process.send_after(self(), :no_access, 10)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,8 @@ defmodule WandererAppWeb.MapsLive do
|
||||
|
||||
alias BetterNumber, as: Number
|
||||
|
||||
@pubsub_client Application.compile_env(:wanderer_app, :pubsub_client)
|
||||
|
||||
@impl true
|
||||
def mount(_params, %{"user_id" => user_id} = _session, socket) when not is_nil(user_id) do
|
||||
{:ok, active_characters} = WandererApp.Api.Character.active_by_user(%{user_id: user_id})
|
||||
@@ -112,6 +114,13 @@ defmodule WandererAppWeb.MapsLive do
|
||||
"auto_renew?" => true
|
||||
}
|
||||
|
||||
options_form =
|
||||
map.options
|
||||
|> case do
|
||||
nil -> %{"layout" => "left_to_right"}
|
||||
options -> Jason.decode!(options)
|
||||
end
|
||||
|
||||
{:ok, estimated_price, discount} =
|
||||
WandererApp.Map.SubscriptionManager.estimate_price(subscription_form, false)
|
||||
|
||||
@@ -130,6 +139,7 @@ defmodule WandererAppWeb.MapsLive do
|
||||
active_settings_tab: "general",
|
||||
is_adding_subscription?: false,
|
||||
selected_subscription: nil,
|
||||
options_form: options_form |> to_form(),
|
||||
map_subscriptions: map_subscriptions,
|
||||
subscription_form: subscription_form |> to_form(),
|
||||
estimated_price: estimated_price,
|
||||
@@ -142,6 +152,10 @@ defmodule WandererAppWeb.MapsLive do
|
||||
{"3 Months", "3"},
|
||||
{"6 Months", "6"},
|
||||
{"1 Year", "12"}
|
||||
],
|
||||
layout_options: [
|
||||
{"Left To Right", "left_to_right"},
|
||||
{"Top To Bottom", "top_to_bottom"}
|
||||
]
|
||||
)
|
||||
|> allow_upload(:settings,
|
||||
@@ -653,6 +667,28 @@ defmodule WandererAppWeb.MapsLive do
|
||||
|> push_patch(to: ~p"/maps")}
|
||||
end
|
||||
|
||||
def handle_event(
|
||||
"update_options",
|
||||
%{
|
||||
"layout" => layout
|
||||
} = options_form,
|
||||
%{assigns: %{map_id: map_id, map: map, current_user: current_user}} = socket
|
||||
) do
|
||||
options = %{layout: layout}
|
||||
|
||||
updated_map =
|
||||
map
|
||||
|> WandererApp.Api.Map.update_options!(%{options: Jason.encode!(options)})
|
||||
|
||||
@pubsub_client.broadcast(
|
||||
WandererApp.PubSub,
|
||||
"maps:#{map_id}",
|
||||
{:options_updated, options}
|
||||
)
|
||||
|
||||
{:noreply, socket |> assign(map: updated_map, options_form: options_form)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_event("noop", _, socket) do
|
||||
{:noreply, socket}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
>
|
||||
<figure class="absolute z-10 h-200 avatar w-full h-full">
|
||||
<img :if={map.scope === :all} class="absolute h-200" src="/images/all_back.webp" />
|
||||
|
||||
<img
|
||||
:if={map.scope === :wormholes}
|
||||
class="absolute h-200"
|
||||
@@ -190,7 +189,6 @@
|
||||
>
|
||||
<div role="tablist" class="tabs tabs-bordered">
|
||||
<a
|
||||
:if={@map_subscriptions_enabled?}
|
||||
role="tab"
|
||||
phx-click="change_settings_tab"
|
||||
phx-value-tab="general"
|
||||
@@ -201,6 +199,17 @@
|
||||
>
|
||||
<.icon name="hero-wrench-screwdriver-solid" class="w-4 h-4" /> General
|
||||
</a>
|
||||
<a
|
||||
role="tab"
|
||||
phx-click="change_settings_tab"
|
||||
phx-value-tab="import"
|
||||
class={[
|
||||
"tab",
|
||||
classes("tab-active": @active_settings_tab == "import")
|
||||
]}
|
||||
>
|
||||
<.icon name="hero-wrench-screwdriver-solid" class="w-4 h-4" /> Import/Export
|
||||
</a>
|
||||
<a
|
||||
:if={@map_subscriptions_enabled?}
|
||||
role="tab"
|
||||
@@ -227,6 +236,27 @@
|
||||
</a>
|
||||
</div>
|
||||
<.header :if={@active_settings_tab == "general"} class="bordered border-1 border-zinc-800">
|
||||
<:actions>
|
||||
<.form
|
||||
:let={f}
|
||||
:if={assigns |> Map.get(:options_form, false)}
|
||||
for={@options_form}
|
||||
phx-change="update_options"
|
||||
>
|
||||
<div class="stat-title">Map systems layout</div>
|
||||
<div class="stat-value text-white">
|
||||
<.input
|
||||
type="select"
|
||||
field={f[:layout]}
|
||||
class="p-dropdown p-component p-inputwrapper"
|
||||
placeholder="Map default layout"
|
||||
options={@layout_options}
|
||||
/>
|
||||
</div>
|
||||
</.form>
|
||||
</:actions>
|
||||
</.header>
|
||||
<.header :if={@active_settings_tab == "import"} class="bordered border-1 border-zinc-800">
|
||||
Import/Export Map Settings
|
||||
<:actions>
|
||||
<.form :if={assigns |> Map.get(:import_form, false)} for={@import_form} phx-change="import">
|
||||
|
||||
2
mix.exs
2
mix.exs
@@ -2,7 +2,7 @@ defmodule WandererApp.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
@source_url "https://github.com/wanderer-industries/wanderer"
|
||||
@version "1.2.8"
|
||||
@version "1.3.0"
|
||||
|
||||
def project do
|
||||
[
|
||||
|
||||
21
priv/repo/migrations/20241006092351_add_map_options.exs
Normal file
21
priv/repo/migrations/20241006092351_add_map_options.exs
Normal file
@@ -0,0 +1,21 @@
|
||||
defmodule WandererApp.Repo.Migrations.AddMapOptions do
|
||||
@moduledoc """
|
||||
Updates resources based on their most recent snapshots.
|
||||
|
||||
This file was autogenerated with `mix ash_postgres.generate_migrations`
|
||||
"""
|
||||
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:maps_v1) do
|
||||
add :options, :text
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:maps_v1) do
|
||||
remove :options
|
||||
end
|
||||
end
|
||||
end
|
||||
186
priv/resource_snapshots/repo/maps_v1/20241006092351.json
Normal file
186
priv/resource_snapshots/repo/maps_v1/20241006092351.json
Normal file
@@ -0,0 +1,186 @@
|
||||
{
|
||||
"attributes": [
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"gen_random_uuid()\")",
|
||||
"generated?": false,
|
||||
"primary_key?": true,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "id",
|
||||
"type": "uuid"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "name",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "slug",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "description",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "personal_note",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "[]",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "hubs",
|
||||
"type": [
|
||||
"array",
|
||||
"text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "\"wormholes\"",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "scope",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "false",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "deleted",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "false",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "only_tracked_characters",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "options",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "inserted_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": false,
|
||||
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": null,
|
||||
"size": null,
|
||||
"source": "updated_at",
|
||||
"type": "utc_datetime_usec"
|
||||
},
|
||||
{
|
||||
"allow_nil?": true,
|
||||
"default": "nil",
|
||||
"generated?": false,
|
||||
"primary_key?": false,
|
||||
"references": {
|
||||
"deferrable": false,
|
||||
"destination_attribute": "id",
|
||||
"destination_attribute_default": null,
|
||||
"destination_attribute_generated": null,
|
||||
"index?": false,
|
||||
"match_type": null,
|
||||
"match_with": null,
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"name": "maps_v1_owner_id_fkey",
|
||||
"on_delete": null,
|
||||
"on_update": null,
|
||||
"primary_key?": true,
|
||||
"schema": "public",
|
||||
"table": "character_v1"
|
||||
},
|
||||
"size": null,
|
||||
"source": "owner_id",
|
||||
"type": "uuid"
|
||||
}
|
||||
],
|
||||
"base_filter": null,
|
||||
"check_constraints": [],
|
||||
"custom_indexes": [],
|
||||
"custom_statements": [],
|
||||
"has_create_action": true,
|
||||
"hash": "E5FC6B5F1B9AD5E23163494C7C93A8002F9C812AFC7A26A8C33A344877086A03",
|
||||
"identities": [
|
||||
{
|
||||
"all_tenants?": false,
|
||||
"base_filter": null,
|
||||
"index_name": "maps_v1_unique_slug_index",
|
||||
"keys": [
|
||||
{
|
||||
"type": "atom",
|
||||
"value": "slug"
|
||||
}
|
||||
],
|
||||
"name": "unique_slug",
|
||||
"nils_distinct?": true,
|
||||
"where": null
|
||||
}
|
||||
],
|
||||
"multitenancy": {
|
||||
"attribute": null,
|
||||
"global": null,
|
||||
"strategy": null
|
||||
},
|
||||
"repo": "Elixir.WandererApp.Repo",
|
||||
"schema": null,
|
||||
"table": "maps_v1"
|
||||
}
|
||||
Reference in New Issue
Block a user