tidying stray dev code
This commit is contained in:
parent
326b6624b5
commit
3b5794a401
1 changed files with 14 additions and 17 deletions
|
@ -13,22 +13,21 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
|
||||||
|
|
||||||
socket
|
socket
|
||||||
|> assign_defaults(session)
|
|> assign_defaults(session)
|
||||||
|> assign(:url_valid, :false)
|
|> assign(:url_valid, false)
|
||||||
|> assign(:url_validated, :false)
|
|> assign(:url_validated, false)
|
||||||
|> assign(:tz_valid, :true)
|
|> assign(:tz_valid, true)
|
||||||
|> live_okreply()
|
|> live_okreply()
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_event("validate", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
|
def handle_event("validate", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
|
||||||
socket
|
socket
|
||||||
|> assign(:url_valid, Regex.match?(@url_regex, url) |> IO.inspect(label: "url valid?"))
|
|> assign(:url_valid, Regex.match?(@url_regex, url))
|
||||||
|> assign(:url_validated, true)
|
|> assign(:url_validated, true)
|
||||||
|> assign(:tz_valid, Enum.member?(Tzdata.zone_list(), tz))
|
|> assign(:tz_valid, Enum.member?(Tzdata.zone_list(), tz))
|
||||||
|> live_noreply()
|
|> live_noreply()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def handle_event("save", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
|
def handle_event("save", %{"ics_import" => %{"ics_url" => url, "time_zone" => tz}}, socket) do
|
||||||
url
|
url
|
||||||
|
@ -57,10 +56,6 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
|
||||||
defp handle_parsed_ics_data([], socket, tz), do: handle_http_ics_response(false, socket, tz)
|
defp handle_parsed_ics_data([], socket, tz), do: handle_http_ics_response(false, socket, tz)
|
||||||
|
|
||||||
defp handle_parsed_ics_data(events, socket, tz) do
|
defp handle_parsed_ics_data(events, socket, tz) do
|
||||||
IO.inspect(events, label: "We got some ical events! :")
|
|
||||||
IO.inspect(tz, label: "time zone was :")
|
|
||||||
|
|
||||||
to_insert =
|
|
||||||
events
|
events
|
||||||
|> Stream.map(&shift_from_event(&1, tz, socket.assigns.current_user.id))
|
|> Stream.map(&shift_from_event(&1, tz, socket.assigns.current_user.id))
|
||||||
|> Enum.map(&Repo.timestamp/1)
|
|> Enum.map(&Repo.timestamp/1)
|
||||||
|
@ -81,14 +76,16 @@ defmodule Shift73kWeb.ShiftImportLive.Index do
|
||||||
if n == event_count do
|
if n == event_count do
|
||||||
{:success, "Successfully imported #{n} event#{s}"}
|
{:success, "Successfully imported #{n} event#{s}"}
|
||||||
else
|
else
|
||||||
{:warning, "Some error, only #{n} event#{s} imported but seemed like iCal contained #{event_count}?"}
|
{:warning,
|
||||||
|
"Some error, only #{n} event#{s} imported but seemed like iCal contained #{
|
||||||
|
event_count
|
||||||
|
}?"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
put_flash(socket, status, msg)
|
put_flash(socket, status, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
defp content_type_calendar?(headers) do
|
defp content_type_calendar?(headers) do
|
||||||
headers
|
headers
|
||||||
|> List.keyfind("Content-Type", 0)
|
|> List.keyfind("Content-Type", 0)
|
||||||
|
|
Loading…
Reference in a new issue