prop/lib/microwaveprop_web/controllers/beacon_monitor_controller.ex
Graham McIntire fb49eb016d
feat(monitors): schema migration + remove user self-service creation
- Add hardware/config fields migration to beacon_monitors table
- Update BeaconMonitor schema with provision/config changesets
- Add context functions: create_hardware, update_config, list_all_monitors
- Remove user-facing monitor creation (browser POST + API POST)
- Update settings page: show assigned monitors table with hardware info
- Update profile page: show assigned monitors, remove register links
- Fix all tests to match new API
2026-07-21 18:28:51 -05:00

18 lines
542 B
Elixir

defmodule MicrowavepropWeb.BeaconMonitorController do
use MicrowavepropWeb, :controller
alias Microwaveprop.BeaconMonitors
@spec delete(Plug.Conn.t(), map()) :: Plug.Conn.t()
def delete(conn, %{"id" => id}) do
user = conn.assigns.current_scope.user
conn =
case BeaconMonitors.delete_monitor(user, id) do
{:ok, _monitor} -> put_flash(conn, :info, "Monitor deleted.")
{:error, :not_found} -> put_flash(conn, :error, "Monitor not found.")
end
redirect(conn, to: ~p"/users/settings")
end
end