mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
68 lines
1.7 KiB
Elixir
68 lines
1.7 KiB
Elixir
defmodule TeslaMateWeb.Router do
|
|
use TeslaMateWeb, :router
|
|
|
|
alias TeslaMateWeb.Plugs.Donate
|
|
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.SetLocale,
|
|
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 Donate
|
|
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
|
|
get "/donate", DonateController, :index
|
|
|
|
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
|
|
|
|
defp fetch_settings(conn, _opts) do
|
|
settings = Settings.get_global_settings!()
|
|
|
|
conn
|
|
|> assign(:settings, settings)
|
|
|> put_session(:settings, settings)
|
|
end
|
|
end
|