Added presets to cutoff date selector (#494)
This commit is contained in:
parent
75fb1a6ab9
commit
0fb971dd0a
2 changed files with 46 additions and 10 deletions
|
|
@ -27,6 +27,18 @@ defmodule PinchflatWeb.Sources.SourceHTML do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cutoff_date_presets do
|
||||||
|
[
|
||||||
|
{"7 days", compute_date_offset(7)},
|
||||||
|
{"14 days", compute_date_offset(14)},
|
||||||
|
{"30 days", compute_date_offset(30)},
|
||||||
|
{"60 days", compute_date_offset(60)},
|
||||||
|
{"90 days", compute_date_offset(90)},
|
||||||
|
{"180 days", compute_date_offset(180)},
|
||||||
|
{"365 days", compute_date_offset(365)}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def rss_feed_url(conn, source) do
|
def rss_feed_url(conn, source) do
|
||||||
url(conn, ~p"/sources/#{source.uuid}/feed") <> ".xml"
|
url(conn, ~p"/sources/#{source.uuid}/feed") <> ".xml"
|
||||||
end
|
end
|
||||||
|
|
@ -55,4 +67,13 @@ defmodule PinchflatWeb.Sources.SourceHTML do
|
||||||
Must end with .{{ ext }}. Same rules as Media Profile output path templates. #{help_button} to load your media profile's output template
|
Must end with .{{ ext }}. Same rules as Media Profile output path templates. #{help_button} to load your media profile's output template
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp compute_date_offset(days) do
|
||||||
|
timezone = Application.get_env(:pinchflat, :timezone)
|
||||||
|
|
||||||
|
timezone
|
||||||
|
|> Timex.now()
|
||||||
|
|> Timex.shift(days: -days)
|
||||||
|
|> Timex.format!("{YYYY}-{0M}-{0D}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -111,16 +111,31 @@
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<.input
|
<section x-data={"{ cutoffDate: '#{f[:download_cutoff_date].value}' }"}>
|
||||||
field={f[:download_cutoff_date]}
|
<.input
|
||||||
type="text"
|
field={f[:download_cutoff_date]}
|
||||||
label="Download Cutoff Date"
|
type="text"
|
||||||
placeholder="YYYY-MM-DD"
|
label="Download Cutoff Date"
|
||||||
maxlength="10"
|
placeholder="YYYY-MM-DD"
|
||||||
pattern="((?:19|20)[0-9][0-9])-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])"
|
maxlength="10"
|
||||||
title="YYYY-MM-DD"
|
pattern="((?:19|20)[0-9][0-9])-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])"
|
||||||
help="Only download media uploaded after this date. Leave blank to download all media. Must be in YYYY-MM-DD format. Old media may be deleted or downloaded if you change this date"
|
title="YYYY-MM-DD"
|
||||||
/>
|
help="Only download media uploaded after this date. Leave blank to download all media. Must be in YYYY-MM-DD format. Old media may be deleted or downloaded if you change this date"
|
||||||
|
x-model="cutoffDate"
|
||||||
|
>
|
||||||
|
<:input_append>
|
||||||
|
<.input
|
||||||
|
prompt="Select preset"
|
||||||
|
name="download_cutoff_date_preset"
|
||||||
|
value=""
|
||||||
|
options={cutoff_date_presets()}
|
||||||
|
type="select"
|
||||||
|
inputclass="w-30 lg:w-60 ml-2 md:ml-4"
|
||||||
|
x-on:change={"cutoffDate = $event.target.value || '#{f[:download_cutoff_date].value}'"}
|
||||||
|
/>
|
||||||
|
</:input_append>
|
||||||
|
</.input>
|
||||||
|
</section>
|
||||||
|
|
||||||
<.input
|
<.input
|
||||||
field={f[:retention_period_days]}
|
field={f[:retention_period_days]}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue