analytics/lib/plausible_web.ex

131 lines
3.1 KiB
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
defmodule PlausibleWeb do
def live_view(opts \\ []) do
quote do
use Plausible
use Phoenix.LiveView, global_prefixes: ~w(x-)
use PlausibleWeb.Live.Flash
2024-09-03 12:34:37 +03:00
use PlausibleWeb.Live.AuthContext
unless :no_sentry_context in unquote(opts) do
use PlausibleWeb.Live.SentryContext
end
alias PlausibleWeb.Router.Helpers, as: Routes
alias Phoenix.LiveView.JS
Rework settings UI (#4626) * Update generic components library * Import generic components via `PlausibleWeb` * Update Settings/Danger Zone * Update new shared link template and convert to heex * Update site settings layout * Update site settings sidebar tab layout * Update Settings/Email Reports * Update Funnels * Update ComboBox * Extend/update form components * Update Modal live component * Update Settings/Goals * Update Shields * Update Settings/Props * Update Settings/Import & Export * Update flow progress * Import Routes in settings * Update Billing components * Update Billing notice component * Update feature toggle component * Update 2fa component * Update verification markup * Update installation * Update Settings/Integrations/Plugins * Update domain change markup * Update Settings/General * Update Settings/Integrations * Update Settings/People * Update Settings/Integrations/GSC * Update Settings/Visiblity * ukuwip * ukuwip * Tables & paddings * Imports exports * Brighten disabled input text color for dark mode * Tune down table border/divider in dark mode * Format * Fix goal list on mobile * Fix IP Shields table on mobile * Fix country shields list on mobile * Fix country shield list on mobile * Fix page shields list on mobile * Fix import/export settings on mobile * Fix combobox dropdown background in dark mode * Fix filter bar search input on mobile * Revert @ukutaht's changes to goal list * Maybe maybe maybe * Revert the current prod goal list + fix mobile issues * Format * Revert tests change cc @ukutaht * Fix markup expectation in a test * Set autocomplete="off" again * Bring back `text-sm` where previously removed --------- Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-10-02 12:05:21 +03:00
import PlausibleWeb.Components.Generic
import PlausibleWeb.Live.Components.Form
end
end
def live_component do
quote do
use Phoenix.LiveComponent, global_prefixes: ~w(x-)
import PlausibleWeb.Components.Generic
import PlausibleWeb.Live.Components.Form
alias Phoenix.LiveView.JS
alias PlausibleWeb.Router.Helpers, as: Routes
end
end
def component do
quote do
use Phoenix.Component, global_prefixes: ~w(x-)
import PlausibleWeb.Components.Generic
import PlausibleWeb.Live.Components.Form
alias Phoenix.LiveView.JS
alias PlausibleWeb.Router.Helpers, as: Routes
end
end
2019-09-02 14:29:19 +03:00
def controller do
quote do
use Phoenix.Controller, namespace: PlausibleWeb
import Plug.Conn
import PlausibleWeb.ControllerHelpers
alias PlausibleWeb.Router.Helpers, as: Routes
end
end
def view do
quote do
use Phoenix.View,
root: "lib/plausible_web/templates",
namespace: PlausibleWeb
# Import convenience functions from controllers
import Phoenix.Controller, only: [view_module: 1]
2019-09-02 14:29:19 +03:00
use Phoenix.Component
2021-01-13 18:04:01 +03:00
2019-09-02 14:29:19 +03:00
import PlausibleWeb.ErrorHelpers
import PlausibleWeb.Components.Generic
Account settings w sidebar (#4654) * Outline /settings/v2 fundamentals * Add setting tiles stubs * Bootstrap name change * Bootstrap theme change * Bootstrap security settings * Use table component for listing sessions * Disable current e-mail field * Implement Danger Zone * Deal with compilation warnings * Implement "Subscription" section * Implement invoices list * Fix invoices empty state & add API keys * Fix headings in Subscription section * Fix API keys mobile view * Fix subscription boxes width * Fix formatting * Move tests for settings WIP * Adjust remaining tests and router placement Include docs links in tiles, where applicable. * Fix remaining routes and remove dead code * Fix route in a live view where no @conn is available * Update mobile view settings picker * Format * Fix subscription section headings * Fix account e-mail on dark mode * Delete unused template * Fix mobile setting section picker * Optimize Login Management tile for mobile * Update invoices section with docs link * Update copy * Remove trailing dots from (sub)titles * Fix CSV export padding for "exporting" state * Align subscription status to the right * Fix failing test * Fix subscription status alignment once again * Improve subscription mobile view a little * Fixup test compilation 🙈 * Add extra margin to subscription status box * Make cancel button in 2FA modals expand in mobile view * Stats API only * Capitalize "Current session" indicator * Show "Show More" invoices button only when there's >12 * tiny change * Update changelog --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> Co-authored-by: Marko Saric <34340819+metmarkosaric@users.noreply.github.com>
2024-10-08 11:30:01 +03:00
import PlausibleWeb.Live.Components.Form
2019-09-02 14:29:19 +03:00
alias PlausibleWeb.Router.Helpers, as: Routes
end
end
def router do
quote do
use Phoenix.Router
import Plug.Conn
import Phoenix.Controller
end
end
def channel do
quote do
use Phoenix.Channel
end
end
def plugins_api_controller do
quote do
use Phoenix.Controller, namespace: PlausibleWeb.Plugins.API
import Plug.Conn
import PlausibleWeb.Router.Helpers
alias PlausibleWeb.Plugins.API.Schemas
alias PlausibleWeb.Plugins.API.Views
Plugins API: 2nd pass with Goals resource + SharedLinks schema changes (#3396) * Remove "Context" namespace level * Change Goal string representation * Alias Schemas in Plugin API Test Case template * Update schema & tests for SharedLink resource * Update Goals interface - make it possible to create revenue goals - extract "for site" query to a standalone function * Fixup typespecs * Alias Errors module in OpenAPI controllers * Add missing goals test * Implement Goals Plugins API resource * Add extra test to confirm changeset error propagation * Mute credo * Fix typos * Handle changeset traversal in `Errors` * Use upserts in `Goals.find_or_create` * Extract touch_site! to Site.Cache, address credo, improve code docs * Apply formatting * Remove unused inner join * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update test/plausible_web/plugins/api/controllers/goals_test.exs Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com> * Update error message on revenue goal currency clash * Remove unused code --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2023-10-05 12:54:18 +03:00
alias PlausibleWeb.Plugins.API.Errors
alias Plausible.Plugins.API
plug(OpenApiSpex.Plug.CastAndValidate, json_render_error_v2: true, replace_params: false)
use OpenApiSpex.ControllerSpecs
end
end
def plugins_api_view do
quote do
use Phoenix.View,
namespace: PlausibleWeb.Plugins.API,
root: ""
alias PlausibleWeb.Router.Helpers
import PlausibleWeb.Plugins.API.Views.Pagination, only: [render_metadata_links: 4]
end
end
def open_api_schema do
quote do
require OpenApiSpex
alias OpenApiSpex.Schema
alias PlausibleWeb.Plugins.API.Schemas
end
end
2019-09-02 14:29:19 +03:00
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
defmacro __using__([{which, opts}]) when is_atom(which) do
apply(__MODULE__, which, [List.wrap(opts)])
end
2019-09-02 14:29:19 +03:00
end