diff --git a/assets/css/app.css b/assets/css/app.css
index d1ea3d7..9de23e2 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -105,6 +105,6 @@ main.container,
cursor: progress;
}
-.login-container {
+.page-container {
padding: 10px;
}
diff --git a/config/runtime.exs b/config/runtime.exs
index 05d6c7c..4e200df 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -76,7 +76,10 @@ config :geo_therminator,
),
api_device_temp_set_reg_index: 3,
api_device_reg_set_client_id: get_env("API_DEVICE_REG_SET_CLIENT_ID"),
- api_refresh: 10_000
+ api_refresh: 10_000,
+
+ # Database directory for settings, relative to app HOME path
+ db_dir: get_env("DB_DIR", "db")
if config_env() == :dev do
config :geo_therminator, GeoTherminatorWeb.Endpoint,
diff --git a/lib/geo_therminator/application.ex b/lib/geo_therminator/application.ex
index 9ae010a..22553fc 100644
--- a/lib/geo_therminator/application.ex
+++ b/lib/geo_therminator/application.ex
@@ -7,7 +7,10 @@ defmodule GeoTherminator.Application do
@impl true
def start(_type, _args) do
+ db_dir = System.get_env("HOME") |> Path.join(Application.get_env(:geo_therminator, :db_dir))
+
children = [
+ {CubDB, name: GeoTherminator.DB, data_dir: db_dir},
{Finch, name: GeoTherminator.PumpAPI.HTTP},
{Phoenix.PubSub, name: GeoTherminator.PumpAPI.Device.PubSub},
{Registry, keys: :unique, name: GeoTherminator.PumpAPI.Device.Registry},
diff --git a/lib/geo_therminator_web/live/main/device_list.ex b/lib/geo_therminator_web/live/main/device_list.ex
index 25e37b0..ee20248 100644
--- a/lib/geo_therminator_web/live/main/device_list.ex
+++ b/lib/geo_therminator_web/live/main/device_list.ex
@@ -1,8 +1,10 @@
defmodule GeoTherminatorWeb.MainLive.DeviceList do
use GeoTherminatorWeb, :live_view
- @impl true
+ @impl Phoenix.LiveView
def mount(_params, _session, socket) do
+ CubDB.delete(GeoTherminator.DB, :viewing_pump)
+
user = GeoTherminator.PumpAPI.Auth.Server.get_auth(GeoTherminator.PumpAPI.Auth.Server)
installations =
@@ -10,4 +12,17 @@ defmodule GeoTherminatorWeb.MainLive.DeviceList do
{:ok, assign(socket, user: user, installations: installations)}
end
+
+ @impl Phoenix.LiveView
+ def handle_event(evt, value, socket)
+
+ def handle_event("logout", _value, socket) do
+ DynamicSupervisor.stop(GeoTherminator.PumpAPI.Auth.Server.Supervisor)
+ CubDB.delete(GeoTherminator.DB, :auth_credentials)
+
+ {:noreply,
+ Phoenix.LiveView.push_redirect(socket,
+ to: Routes.live_path(socket, GeoTherminatorWeb.MainLive.Index)
+ )}
+ end
end
diff --git a/lib/geo_therminator_web/live/main/device_list.html.heex b/lib/geo_therminator_web/live/main/device_list.html.heex
index 52e57b0..51cba2a 100644
--- a/lib/geo_therminator_web/live/main/device_list.html.heex
+++ b/lib/geo_therminator_web/live/main/device_list.html.heex
@@ -1,4 +1,4 @@
-Welcome, <%= @user.first_name %>!