@@ -53,7 +53,9 @@ defmodule DashboardWeb.Live.ConfigLive do
5353 tooltip = "TODO: popup title "
5454 placeholder = "Worker count " >
5555 <: input let = { f } >
56- <%= text_input f , :worker_count , type: "number" , class: "form-control" , placeholder: "Worker count" %>
56+ <%= text_input f , :worker_count , type: "number" , class: "form-control" , placeholder: "Worker count" ,
57+ max: @ constraints . worker_count . max , min: @ constraints . worker_count . min %>
58+ <%= error_tag ( f , :worker_count ) %>
5759 </: input >
5860 </ . config_item >
5961
@@ -64,7 +66,9 @@ defmodule DashboardWeb.Live.ConfigLive do
6466 tooltip = "TODO: popup title "
6567 placeholder = "Chunk Size " >
6668 <: input let = { f } >
67- <%= text_input f , :schema_infer_chunk_size , type: "number" , class: "form-control" , placeholder: "Chunk Size" %>
69+ <%= text_input f , :schema_infer_chunk_size , type: "number" , class: "form-control" , placeholder: "Chunk Size" ,
70+ max: @ constraints . schema_infer_chunk_size . max , min: @ constraints . schema_infer_chunk_size . min %>
71+ <%= error_tag ( f , :schema_infer_chunk_size ) %>
6872 </: input >
6973 </ . config_item >
7074
@@ -104,7 +108,7 @@ defmodule DashboardWeb.Live.ConfigLive do
104108 </ div >
105109
106110 <!-- Database Configurations -->
107- < div class = "card m-4 d-flex w-75 m-auto mt-4 " >
111+ < div class = { "card m-4 d-flex w-75 m-auto mt-4 #{ unless ( db_needed ( @ changeset ) , do: "invisible" ) } " } >
108112 < header >
109113 < IconSvg . db_settings class = "m-2 " />
110114 < span class = "font-monospace small fst-italic fw-bold " > Database Configurations </ span >
@@ -123,7 +127,7 @@ defmodule DashboardWeb.Live.ConfigLive do
123127 <: input let = { f } >
124128 < div class = "d-flex flex-column " >
125129 < div class = "form-check " >
126- <%= radio_button f , :db_type , :mysql , class: "form-check-input mt-4" , id: "mysql_db_type" , checked: "checked" %>
130+ <%= radio_button f , :db_type , :mysql , class: "form-check-input mt-4" , id: "mysql_db_type" , checked: "checked" , disable: ! db_needed ( @ changeset ) %>
127131 < label class = "form-check-label mysql-label " for = "mysql_db_type " >
128132 < IconSvg . mysql_icon { % { width: 100 , height: 100 } } />
129133 </ label >
@@ -237,7 +241,9 @@ defmodule DashboardWeb.Live.ConfigLive do
237241 tooltip = "TODO: popup title "
238242 placeholder = "Varchar size " >
239243 <: input let = { f } >
240- <%= text_input f , :varchar_limit , type: "number" , class: "form-control" , placeholder: "Varchar size" %>
244+ <%= text_input f , :varchar_limit , type: "number" , class: "form-control" , placeholder: "Varchar size" ,
245+ max: @ constraints . varchar_limit . max , min: @ constraints . varchar_limit . min %>
246+ <%= error_tag ( f , :varchar_limit ) %>
241247 </: input >
242248 </ . config_item >
243249
@@ -249,7 +255,9 @@ defmodule DashboardWeb.Live.ConfigLive do
249255 tooltip = "TODO: popup title "
250256 placeholder = "DB Worker count " >
251257 <: input let = { f } >
252- <%= text_input f , :db_worker_count , type: "number" , class: "form-control" , placeholder: "DB Worker count" %>
258+ <%= text_input f , :db_worker_count , type: "number" , class: "form-control" , placeholder: "DB Worker count" ,
259+ max: @ constraints . db_worker_count . max , min: @ constraints . db_worker_count . min %>
260+ <%= error_tag ( f , :db_worker_count ) %>
253261 </: input >
254262 </ . config_item >
255263
@@ -260,7 +268,9 @@ defmodule DashboardWeb.Live.ConfigLive do
260268 tooltip = "TODO: popup title "
261269 placeholder = "Insertion Chunk Size " >
262270 <: input let = { f } >
263- <%= text_input f , :insertion_chunk_size , type: "number" , class: "form-control" , placeholder: "Insertion Chunk size" %>
271+ <%= text_input f , :insertion_chunk_size , type: "number" , class: "form-control" , placeholder: "Insertion Chunk size" ,
272+ max: @ constraints . insertion_chunk_size . max , min: @ constraints . insertion_chunk_size . min %>
273+ <%= error_tag ( f , :insertion_chunk_size ) %>
264274 </: input >
265275 </ . config_item >
266276 </ div >
@@ -296,4 +306,9 @@ defmodule DashboardWeb.Live.ConfigLive do
296306 </ . form >
297307 """
298308 end
309+
310+ defp db_needed ( changeset ) do
311+ Ecto.Changeset . get_field ( changeset , :insert_schema ) ||
312+ Ecto.Changeset . get_field ( changeset , :insert_data )
313+ end
299314end
0 commit comments