Make timezone configurable
This commit is contained in:
+4
-1
@@ -15,7 +15,10 @@ config :music_library,
|
|||||||
ecto_repos: [MusicLibrary.Repo, MusicLibrary.ErrorRepo],
|
ecto_repos: [MusicLibrary.Repo, MusicLibrary.ErrorRepo],
|
||||||
generators: [timestamp_type: :utc_datetime, binary_id: true]
|
generators: [timestamp_type: :utc_datetime, binary_id: true]
|
||||||
|
|
||||||
config :music_library, MusicLibraryWeb, login_password: "change me", api_token: "change me"
|
config :music_library, MusicLibraryWeb,
|
||||||
|
login_password: "change me",
|
||||||
|
api_token: "change me",
|
||||||
|
timezone: "Europe/London"
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :music_library, MusicLibraryWeb.Endpoint,
|
config :music_library, MusicLibraryWeb.Endpoint,
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ if openai_key = System.get_env("OPENAI_KEY") do
|
|||||||
config :music_library, OpenAI, api_key: openai_key
|
config :music_library, OpenAI, api_key: openai_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if timezone = System.get_env("TIMEZONE") do
|
||||||
|
config :music_library, :timezone, timezone
|
||||||
|
end
|
||||||
|
|
||||||
config :music_library, MusicLibrary.Repo,
|
config :music_library, MusicLibrary.Repo,
|
||||||
load_extensions: [
|
load_extensions: [
|
||||||
MusicLibrary.Repo.extension_path("unicode")
|
MusicLibrary.Repo.extension_path("unicode")
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ PHX_HOST = 'music-library.claudio-ortolina.org'
|
|||||||
PORT = '8080'
|
PORT = '8080'
|
||||||
LAST_FM_USER = 'cloud8421'
|
LAST_FM_USER = 'cloud8421'
|
||||||
POOL_SIZE = '5'
|
POOL_SIZE = '5'
|
||||||
|
TIMEZONE = 'Europe/London'
|
||||||
|
|
||||||
[[mounts]]
|
[[mounts]]
|
||||||
source = 'music_library'
|
source = 'music_library'
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
attr :title, :string, required: true
|
attr :title, :string, required: true
|
||||||
attr :class, :string
|
attr :class, :string
|
||||||
|
|
||||||
@timezone "Europe/London"
|
|
||||||
|
|
||||||
defp album_preview(assigns) do
|
defp album_preview(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div
|
<div
|
||||||
@@ -85,6 +83,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
|
|
||||||
{:ok,
|
{:ok,
|
||||||
socket
|
socket
|
||||||
|
|> assign(:timezone, resolve_timezone!())
|
||||||
|> stream_configure(:recent_tracks,
|
|> stream_configure(:recent_tracks,
|
||||||
dom_id: fn track -> "track-#{track.scrobbled_at_uts}" end
|
dom_id: fn track -> "track-#{track.scrobbled_at_uts}" end
|
||||||
)
|
)
|
||||||
@@ -173,7 +172,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
Enum.map(recent_tracks, fn t ->
|
Enum.map(recent_tracks, fn t ->
|
||||||
%{
|
%{
|
||||||
t
|
t
|
||||||
| scrobbled_at_label: localize_scrobbled_at(t.scrobbled_at_uts, @timezone)
|
| scrobbled_at_label: localize_scrobbled_at(t.scrobbled_at_uts, socket.assigns.timezone)
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -272,4 +271,9 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
JS.hide(to: "#actions-#{track_id}")
|
JS.hide(to: "#actions-#{track_id}")
|
||||||
|> JS.remove_class("pointer-events-none", to: "#scrobble-activity > li")
|
|> JS.remove_class("pointer-events-none", to: "#scrobble-activity > li")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp resolve_timezone! do
|
||||||
|
Application.get_env(:music_library, MusicLibraryWeb)
|
||||||
|
|> Keyword.fetch!(:timezone)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user