diff --git a/assets/js/app.js b/assets/js/app.js index 7cdf64bc8..1b5a24221 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -17,8 +17,9 @@ import LiveReact, { initLiveReact } from "phoenix_live_react"; import sourceLiveViewHooks from "./source_lv_hooks"; import logsLiveViewHooks from "./log_event_live_hooks"; - +import $ from "jquery" import moment from "moment"; + // set moment globally before daterangepicker window.moment = moment; @@ -100,4 +101,24 @@ window.liveSocket = liveSocket; document.addEventListener("DOMContentLoaded", (e) => { initLiveReact(); + +}); + +// Use `:text` on the `:detail` optoin to pass values to event listener +window.addEventListener("logflare:copy-to-clipboard", (event) => { + if ("clipboard" in navigator) { + const text = event.detail?.text || event.target.textContent; + navigator.clipboard.writeText(text); + } else { + console.error("Your browser does not support clipboard copy."); + } }); + + +window.addEventListener("phx:page-loading-stop", _info => { + // enable all tooltips + $(function () { + $('[data-toggle="tooltip"]').tooltip({delay: {show: 100, hide: 200}}) + }); + +}) diff --git a/lib/logflare_web.ex b/lib/logflare_web.ex index eec7a72a7..f9db24f9a 100644 --- a/lib/logflare_web.ex +++ b/lib/logflare_web.ex @@ -123,6 +123,7 @@ defmodule LogflareWeb do quote do use LogflareWeb.LiveCommons use LogflareWeb.ModalLiveHelpers + alias Phoenix.LiveView.JS end end diff --git a/lib/logflare_web/core_components.ex b/lib/logflare_web/core_components.ex index c006fe298..b5a8cfa31 100644 --- a/lib/logflare_web/core_components.ex +++ b/lib/logflare_web/core_components.ex @@ -8,11 +8,12 @@ defmodule LogflareWeb.CoreComponents do attr :variant, :string, values: ["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"] + attr :class, :string, required: false, default: "" slot :inner_block, required: true def alert(assigns) do ~H""" -