3.0 KiB · text History 9c0fc16
defmodule LambentExWeb.Router do
  use LambentExWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_live_flash
    plug :put_root_layout, {LambentExWeb.Layouts, :root}
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", LambentExWeb do
    pipe_through :browser

    live "/", IndexLive.Index, :index

    live "/cfg/devices", DevicesLive.Index, :index
    live "/cfg/devices/versions", DevicesLive.Versions, :index
    live "/cfg/devices/interfaces", DevicesLive.Interfaces, :index
    live "/cfg/devices/places", DevicesLive.Places, :index
    live "/cfg/brightness", BrightnessLive.Index, :index
    live "/cfg/machines", MachinesLive.Index, :index
    live "/cfg/machines/new", MachinesLive.Index, :new
    live "/cfg/machines/library", MachinesLive.Index, :library
    live "/cfg/links", LinksLive.Index, :index
    live "/cfg/links/new", LinksLive.Index, :new
    live "/cfg/links/bulk", LinksLive.Index, :bulk
    live "/cfg/services", ServicesLive.Index, :index
    live "/cfg/services/mqtt", ServicesLive.Index, :new_mqtt
    live "/cfg/services/http", ServicesLive.Index, :new_http
    live "/cfg/services/cronos", ServicesLive.Index, :new_cronos
    #    live "/cfg/devices/:id", DevicesLive.Show, :show
    #    live "/cfg/devices/:id/show/edit", DevicesLive.Show, :edit
  end

  # Other scopes may use custom stacks.
  scope "/api", LambentExWeb do
    pipe_through :api
    resources "/data/:path", DataController, only: [:create, :index]
#    resources "/cfg/devices", DeviceController, only: [:index]
#    resources "/cfg/machines", MachineController, only: [:index, :create, :show, :edit]
#    resources "/cfg/machines/library", MachineControllerLib, only: [:index]
#    resources "/cfg/machines/:id/:action", MachineControlleraction, only: [:create] # faster/slower/brighter/dimmer/pin
#    resources "/cfg/links", LinkController, only: [:index, :create, :show, :edit]
#    resources "/cfg/links/:id/:action", LinkControllerAction, only: [:create] # toggle//pin
#    resources "/cfg/links/bulk", LinkControllerBulk, only: [:create]
#    resources "/cfg/services/mqtt", MQTTController, only: [:index, ]
#    resources "/cfg/services/http", HTTPController, only: [:index, ]
#    resources "/cfg/services/cronos", HTTPController, only: [:index, ]
  end

  # Enable LiveDashboard in development
  if Application.compile_env(:lambent_ex, :dev_routes) do
    # If you want to use the LiveDashboard in production, you should put
    # it behind authentication and allow only admins to access it.
    # If your application does not have an admins-only section yet,
    # you can use Plug.BasicAuth to set up some basic authentication
    # as long as you are also using SSL (which you should anyway).
    import Phoenix.LiveDashboard.Router

    scope "/dev" do
      pipe_through :browser

      live_dashboard "/dashboard", metrics: LambentExWeb.Telemetry
    end
  end
end