From e74154581c31034be095f6d0671a76e62f2b9573 Mon Sep 17 00:00:00 2001 From: carla Date: Mon, 2 Feb 2026 10:10:02 +0100 Subject: [PATCH] feat: changes UI info based on config for limits --- lib/mv/config.ex | 19 +++++++++++++++++++ lib/mv_web/live/global_settings_live.ex | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/mv/config.ex b/lib/mv/config.ex index edf8428..98a5b65 100644 --- a/lib/mv/config.ex +++ b/lib/mv/config.ex @@ -62,6 +62,25 @@ defmodule Mv.Config do get_csv_import_config(:max_rows, 1000) end + @doc """ + Returns the maximum file size for CSV imports in megabytes. + + Reads the `max_file_size_mb` value from the CSV import configuration. + + ## Returns + + - Maximum file size in megabytes (default: 10) + + ## Examples + + iex> Mv.Config.csv_import_max_file_size_mb() + 10 + """ + @spec csv_import_max_file_size_mb() :: pos_integer() + def csv_import_max_file_size_mb do + get_csv_import_config(:max_file_size_mb, 10) + end + # Helper function to get CSV import config values defp get_csv_import_config(key, default) do Application.get_env(:mv, :csv_import, []) diff --git a/lib/mv_web/live/global_settings_live.ex b/lib/mv_web/live/global_settings_live.ex index aa41cd5..29cd3f3 100644 --- a/lib/mv_web/live/global_settings_live.ex +++ b/lib/mv_web/live/global_settings_live.ex @@ -34,8 +34,8 @@ defmodule MvWeb.GlobalSettingsLive do ### Limits - - Maximum file size: 10 MB - - Maximum rows: 1,000 rows (excluding header) + - Maximum file size: configurable via `config :mv, csv_import: [max_file_size_mb: ...]` + - Maximum rows: configurable via `config :mv, csv_import: [max_rows: ...]` (excluding header) - Processing: chunks of 200 rows - Errors: capped at 50 per import @@ -74,6 +74,8 @@ defmodule MvWeb.GlobalSettingsLive do |> assign(:import_status, :idle) |> assign(:locale, locale) |> assign(:max_errors, @max_errors) + |> assign(:csv_import_max_rows, Config.csv_import_max_rows()) + |> assign(:csv_import_max_file_size_mb, Config.csv_import_max_file_size_mb()) |> assign_form() # Configure file upload with auto-upload enabled # Files are uploaded automatically when selected, no need for manual trigger @@ -198,7 +200,7 @@ defmodule MvWeb.GlobalSettingsLive do />