[Enhancement] Misc. UI updates (#434)
* Format 'Scheduled At' in task table according to user's TZ * Changed video preview layout to 1 column on all displays * Made links in descriptions clickable * Updated Copy JSON button to properly escape newline characters
This commit is contained in:
@@ -62,17 +62,24 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Renders a block of text with each line broken into a separate span.
|
Renders a block of text with each line broken into a separate span and links highlighted.
|
||||||
"""
|
"""
|
||||||
attr :text, :string, required: true
|
attr :text, :string, required: true
|
||||||
|
|
||||||
def break_on_newline(assigns) do
|
def render_description(assigns) do
|
||||||
broken_text =
|
formatted_text =
|
||||||
assigns.text
|
Regex.split(~r{https?://\S+}, assigns.text, include_captures: true)
|
||||||
|> String.split("\n", trim: false)
|
|> Enum.map(fn
|
||||||
|> Enum.intersperse(Phoenix.HTML.Tag.tag(:span, class: "inline-block mt-2"))
|
"http" <> _ = url ->
|
||||||
|
Phoenix.HTML.Tag.content_tag(:a, url, class: "text-blue-500 hover:text-blue-300", href: url, target: "_blank")
|
||||||
|
|
||||||
assigns = Map.put(assigns, :text, broken_text)
|
text ->
|
||||||
|
text
|
||||||
|
|> String.split("\n", trim: false)
|
||||||
|
|> Enum.intersperse(Phoenix.HTML.Tag.tag(:span, class: "inline-block mt-2"))
|
||||||
|
end)
|
||||||
|
|
||||||
|
assigns = Map.put(assigns, :text, formatted_text)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<span><%= @text %></span>
|
<span><%= @text %></span>
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<:option>
|
<:option>
|
||||||
<span x-data="{ copied: false }" x-on:click={~s"
|
<span x-data="{ copied: false }" x-on:click={~s"
|
||||||
copyWithCallbacks(
|
copyWithCallbacks(
|
||||||
`#{Jason.Formatter.pretty_print(Phoenix.json_library().encode!(@media_item))}`,
|
String.raw`#{Jason.Formatter.pretty_print(Phoenix.json_library().encode!(@media_item))}`,
|
||||||
() => copied = true,
|
() => copied = true,
|
||||||
() => copied = false
|
() => copied = false
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<%= if media_type(@media_item) == :video do %>
|
<%= if media_type(@media_item) == :video do %>
|
||||||
<video controls class="max-h-96 w-full">
|
<video controls class="max-h-128 w-full">
|
||||||
<source src={~p"/media/#{@media_item.uuid}/stream"} type="video/mp4" />
|
<source src={~p"/media/#{@media_item.uuid}/stream"} type="video/mp4" />
|
||||||
Your browser does not support the video element.
|
Your browser does not support the video element.
|
||||||
</video>
|
</video>
|
||||||
|
|||||||
@@ -26,11 +26,12 @@
|
|||||||
<:tab title="Media" id="media">
|
<:tab title="Media" id="media">
|
||||||
<div class="flex flex-col gap-10 dark:text-white">
|
<div class="flex flex-col gap-10 dark:text-white">
|
||||||
<%= if media_file_exists?(@media_item) do %>
|
<%= if media_file_exists?(@media_item) do %>
|
||||||
<section class="grid grid-cols-1 xl:grid-cols-2 xl:gap-6 mt-6">
|
<section class="grid grid-cols-1 xl:gap-6 mt-6">
|
||||||
<div>
|
<div>
|
||||||
<.media_preview media_item={@media_item} />
|
<.media_preview media_item={@media_item} />
|
||||||
</div>
|
</div>
|
||||||
<aside class="mt-4 xl:mt-0">
|
<aside class="mt-4">
|
||||||
|
<h2 class="text-xl mb-2"><%= @media_item.title %></h2>
|
||||||
<div>Uploaded: <%= DateTime.to_date(@media_item.uploaded_at) %></div>
|
<div>Uploaded: <%= DateTime.to_date(@media_item.uploaded_at) %></div>
|
||||||
<div>
|
<div>
|
||||||
<span :if={URI.parse(@media_item.original_url).scheme =~ "http"}>
|
<span :if={URI.parse(@media_item.original_url).scheme =~ "http"}>
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div :if={@media_item.description} class="mt-4 text-bodydark">
|
<div :if={@media_item.description} class="mt-4 text-bodydark">
|
||||||
<.break_on_newline text={@media_item.description} />
|
<.render_description text={@media_item.description} />
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</section>
|
</section>
|
||||||
@@ -70,7 +71,7 @@
|
|||||||
<%= task.job.state %>
|
<%= task.job.state %>
|
||||||
</:col>
|
</:col>
|
||||||
<:col :let={task} label="Scheduled At">
|
<:col :let={task} label="Scheduled At">
|
||||||
<%= Calendar.strftime(task.job.scheduled_at, "%y-%m-%d %I:%M:%S %p %Z") %>
|
<.datetime_in_zone datetime={task.job.scheduled_at} />
|
||||||
</:col>
|
</:col>
|
||||||
</.table>
|
</.table>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<:option>
|
<:option>
|
||||||
<span x-data="{ copied: false }" x-on:click={~s"
|
<span x-data="{ copied: false }" x-on:click={~s"
|
||||||
copyWithCallbacks(
|
copyWithCallbacks(
|
||||||
`#{Jason.Formatter.pretty_print(Phoenix.json_library().encode!(@media_profile))}`,
|
String.raw`#{Jason.Formatter.pretty_print(Phoenix.json_library().encode!(@media_profile))}`,
|
||||||
() => copied = true,
|
() => copied = true,
|
||||||
() => copied = false
|
() => copied = false
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<:option>
|
<:option>
|
||||||
<span x-data="{ copied: false }" x-on:click={~s"
|
<span x-data="{ copied: false }" x-on:click={~s"
|
||||||
copyWithCallbacks(
|
copyWithCallbacks(
|
||||||
`#{Jason.Formatter.pretty_print(Phoenix.json_library().encode!(@source))}`,
|
String.raw`#{Jason.Formatter.pretty_print(Phoenix.json_library().encode!(@source))}`,
|
||||||
() => copied = true,
|
() => copied = true,
|
||||||
() => copied = false
|
() => copied = false
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<%= task.job.state %>
|
<%= task.job.state %>
|
||||||
</:col>
|
</:col>
|
||||||
<:col :let={task} label="Scheduled At">
|
<:col :let={task} label="Scheduled At">
|
||||||
<%= Calendar.strftime(task.job.scheduled_at, "%y-%m-%d %I:%M:%S %p %Z") %>
|
<.datetime_in_zone datetime={task.job.scheduled_at} />
|
||||||
</:col>
|
</:col>
|
||||||
</.table>
|
</.table>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
Reference in New Issue
Block a user