feat: changes UI info based on config for limits
This commit is contained in:
parent
d61a939deb
commit
e74154581c
2 changed files with 24 additions and 3 deletions
|
|
@ -62,6 +62,25 @@ defmodule Mv.Config do
|
||||||
get_csv_import_config(:max_rows, 1000)
|
get_csv_import_config(:max_rows, 1000)
|
||||||
end
|
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
|
# Helper function to get CSV import config values
|
||||||
defp get_csv_import_config(key, default) do
|
defp get_csv_import_config(key, default) do
|
||||||
Application.get_env(:mv, :csv_import, [])
|
Application.get_env(:mv, :csv_import, [])
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
|
|
||||||
### Limits
|
### Limits
|
||||||
|
|
||||||
- Maximum file size: 10 MB
|
- Maximum file size: configurable via `config :mv, csv_import: [max_file_size_mb: ...]`
|
||||||
- Maximum rows: 1,000 rows (excluding header)
|
- Maximum rows: configurable via `config :mv, csv_import: [max_rows: ...]` (excluding header)
|
||||||
- Processing: chunks of 200 rows
|
- Processing: chunks of 200 rows
|
||||||
- Errors: capped at 50 per import
|
- Errors: capped at 50 per import
|
||||||
|
|
||||||
|
|
@ -74,6 +74,8 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
|> assign(:import_status, :idle)
|
|> assign(:import_status, :idle)
|
||||||
|> assign(:locale, locale)
|
|> assign(:locale, locale)
|
||||||
|> assign(:max_errors, @max_errors)
|
|> 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()
|
|> assign_form()
|
||||||
# Configure file upload with auto-upload enabled
|
# Configure file upload with auto-upload enabled
|
||||||
# Files are uploaded automatically when selected, no need for manual trigger
|
# Files are uploaded automatically when selected, no need for manual trigger
|
||||||
|
|
@ -198,7 +200,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
/>
|
/>
|
||||||
<label class="label" id="csv_file_help">
|
<label class="label" id="csv_file_help">
|
||||||
<span class="label-text-alt">
|
<span class="label-text-alt">
|
||||||
{gettext("CSV files only, maximum 10 MB")}
|
{gettext("CSV files only, maximum %{size} MB", size: @csv_import_max_file_size_mb)}
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue