mirror of
https://github.com/netfun2000/hipudding-teslamate.git
synced 2026-02-27 09:44:28 +08:00
* Upgrade to phoenix 1.7.0 The minimal changes necessary to compile the application * Import Phoenix.Component instead of LiveView * Fix compilation warnings * mix format * Update tests to trim newline characters * mix gettext.extract --merge * style: correct linting * rebuild gettext * fix: correct spacing before unit for energy added * fix: use unicode character for whitespace * fix: spacing with witespace * fix: use numeric value for charge_energy_added in charging test * fix: avoid warning about unsued function, which is actually used in plug * fix: use whitespace in test before charge_energy_added --------- Co-authored-by: JakobLichterfeld <jakob-lichterfeld@gmx.de>
65 lines
1.6 KiB
Elixir
65 lines
1.6 KiB
Elixir
defmodule TeslaMateWeb.Router do
|
|
use TeslaMateWeb, :router
|
|
|
|
alias TeslaMate.Settings
|
|
|
|
pipeline :browser do
|
|
plug :accepts, ["html"]
|
|
plug :fetch_session
|
|
plug :fetch_live_flash
|
|
|
|
plug Cldr.Plug.AcceptLanguage,
|
|
cldr_backend: TeslaMateWeb.Cldr,
|
|
no_match_log_level: :debug
|
|
|
|
plug Cldr.Plug.PutLocale,
|
|
apps: [:cldr, :gettext],
|
|
from: [:query, :session, :accept_language],
|
|
gettext: TeslaMateWeb.Gettext,
|
|
cldr: TeslaMateWeb.Cldr
|
|
|
|
plug TeslaMateWeb.Plugs.PutSession
|
|
|
|
plug :put_root_layout, {TeslaMateWeb.LayoutView, :root}
|
|
plug :protect_from_forgery
|
|
plug :put_secure_browser_headers
|
|
plug :fetch_settings
|
|
end
|
|
|
|
pipeline :api do
|
|
plug :accepts, ["json"]
|
|
end
|
|
|
|
scope "/", TeslaMateWeb do
|
|
pipe_through :browser
|
|
|
|
get "/", CarController, :index
|
|
get "/drive/:id/gpx", DriveController, :gpx
|
|
|
|
live_session :default do
|
|
live "/sign_in", SignInLive.Index
|
|
live "/settings", SettingsLive.Index
|
|
live "/geo-fences", GeoFenceLive.Index
|
|
live "/geo-fences/new", GeoFenceLive.Form
|
|
live "/geo-fences/:id/edit", GeoFenceLive.Form
|
|
live "/charge-cost/:id", ChargeLive.Cost
|
|
live "/import", ImportLive.Index
|
|
end
|
|
end
|
|
|
|
scope "/api", TeslaMateWeb do
|
|
pipe_through :api
|
|
|
|
put "/car/:id/logging/resume", CarController, :resume_logging
|
|
put "/car/:id/logging/suspend", CarController, :suspend_logging
|
|
end
|
|
|
|
def fetch_settings(conn, _opts) do
|
|
settings = Settings.get_global_settings!()
|
|
|
|
conn
|
|
|> assign(:settings, settings)
|
|
|> put_session(:settings, settings)
|
|
end
|
|
end
|