defmodule DashboardWeb.Live.StartLive do use DashboardWeb, :live_view def start_page(assigns) do ~H"""
Status: <%= cond do %> <% not @changeset.valid? -> %> Invalid Configurations! <% is_tuple(@state.status) -> %> Error! check logs <% true -> %> <%= show_status(@state.status) %> <% end %>
<%= if not is_nil(@state.validation_status) do %>
Validation Status: <%= @state.validation_status %>!
<% end %> <%= if @state.status != :init do %>
Total Files: <%= Enum.count(Map.values(@state.files)) %>
Files Imported: <%= Enum.count(Map.values(@state.files), fn %{status: status} -> status == :done end) %>
CPU Usage: <%= @cpu_usage %>%
Memory Usage of Application: <%= @memory_usage %>
Time Elapsed: <%= @time_spend %> seconds
<% end %>
<%= Enum.map Map.values(@state.files), fn %{name: name, path: path, size: size, row_count: row_count, rows_processed: rows_processed, status: status} -> %>
Name: <%= name %> Path: <%= path %> Size: <%= size %> Total Number of Records: <%= row_count %> Status: <%= case status do %> <% :pending -> %> Pending <% :analyze -> %> Infering Schema <% :loading -> %> Inserting Data Record Inserted: <%= rows_processed %>
<% percentage_progress=if(row_count==0, do: 100, else: (rows_processed / row_count) * 100) %>
<%= Float.round(percentage_progress * 1.0 , 2) %>%
<% :done -> %> Finished <% end %>
<% end %>
""" end defp item_success_class(status) do if status == :done, do: "list-group-item-success", else: "" end defp error_status_class(status) do if is_tuple(status) or status == :failed, do: "error-status", else: "" end defp spinner_loading_class(status) do if status in [:working, :imported, :validating], do: "spinner loading", else: "" end defp show_status(:imported), do: :working defp show_status(status), do: status defp button_class(changeset) do if not changeset.valid?, do: "button-disabled", else: "button-enabled" end end