mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
* Bump ex_cldr from 2.23.2 to 2.24.1 Bumps [ex_cldr](https://github.com/elixir-cldr/cldr) from 2.23.2 to 2.24.1. - [Release notes](https://github.com/elixir-cldr/cldr/releases) - [Changelog](https://github.com/elixir-cldr/cldr/blob/master/CHANGELOG.md) - [Commits](https://github.com/elixir-cldr/cldr/compare/v2.23.2...v2.24.1) --- updated-dependencies: - dependency-name: ex_cldr dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Replace custom PutSession plug * Bust cldr chache * Bump phoenix_live_view and tzdata Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Adrian Kumpf <8999358+adriankumpf@users.noreply.github.com>
39 lines
988 B
Elixir
39 lines
988 B
Elixir
defmodule TeslaMateWeb.GeoFenceLive.Index do
|
|
use TeslaMateWeb, :live_view
|
|
|
|
alias TeslaMate.{Locations, Settings}
|
|
alias Settings.GlobalSettings
|
|
|
|
alias TeslaMate.Convert
|
|
|
|
on_mount {TeslaMateWeb.InitAssigns, :locale}
|
|
|
|
@impl true
|
|
def mount(_params, %{"settings" => settings}, socket) do
|
|
unit_of_length =
|
|
case settings do
|
|
%GlobalSettings{unit_of_length: :km} -> :m
|
|
%GlobalSettings{unit_of_length: :mi} -> :ft
|
|
end
|
|
|
|
assigns = %{
|
|
geofences: Locations.list_geofences(),
|
|
unit_of_length: unit_of_length,
|
|
page_title: gettext("Geo-Fences")
|
|
}
|
|
|
|
{:ok, assign(socket, assigns)}
|
|
end
|
|
|
|
@impl true
|
|
def handle_event("delete", %{"id" => id}, %{assigns: %{geofences: geofences}} = socket) do
|
|
{:ok, deleted_geofence} =
|
|
Locations.get_geofence!(id)
|
|
|> Locations.delete_geofence()
|
|
|
|
geofences = Enum.reject(geofences, &(&1.id == deleted_geofence.id))
|
|
|
|
{:noreply, assign(socket, geofences: geofences)}
|
|
end
|
|
end
|