-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathemail_config.ml
More file actions
87 lines (84 loc) · 3.09 KB
/
email_config.ml
File metadata and controls
87 lines (84 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
let input_css_classes =
[
"ring-primary-100 mt-1.5 transition appearance-none block w-full px-3 py-3";
"rounded-xl shadow-sm border hover:border-primary-200";
"focus:border-primary-300 bg-primary-50 bg-opacity-0 hover:bg-opacity-50";
"focus:bg-opacity-50 ring-primary-200 focus:ring-primary-200";
"focus:ring-[1px] focus:outline-none";
]
let render_input ~label_text ~name ~id ~input_type ~value () =
Tyxml_html.(
div
~a:[ a_class [ "bg-gray-50 px-4 pb-4 pt-5 sm:p-6 sm:pb-4 my-4" ] ]
[
div
[
label
~a:[ a_class [ "block text-sm font-medium" ]; a_label_for id ]
[ txt label_text ];
input
~a:
[
a_autocomplete `Off;
a_input_type input_type;
a_name name;
a_id id;
a_value value;
a_class input_css_classes;
]
();
];
])
let email_config_layout (current_config : Utils.Email.t option) =
let ip_val, port_val, from_val, base_url_val =
match current_config with
| Some c ->
( Ipaddr.to_string c.server,
string_of_int c.port,
Emile.to_string c.from_email,
c.base_url )
| None -> ("", "", "", "")
in
Tyxml_html.(
section
~a:[ a_class [ "p-4 bg-white rounded-lg shadow-sm" ] ]
[
h2
~a:[ a_class [ "text-lg font-bold text-gray-800 mb-4 px-4" ] ]
[ txt "Email Server Configuration" ];
div
[
p ~a:[ a_id "form-alert"; a_class [ "my-4 hidden" ] ] [];
render_input ~label_text:"Server IP address" ~name:"email_ip"
~id:"email-ip" ~input_type:`Text ~value:ip_val ();
render_input ~label_text:"Server Port" ~name:"email_port"
~id:"email-port" ~input_type:`Number ~value:port_val ();
render_input ~label_text:"From" ~name:"email_from"
~id:"email-sender" ~input_type:`Email ~value:from_val ();
render_input ~label_text:"Base URL" ~name:"base_url" ~id:"base-url"
~input_type:`Text ~value:base_url_val ();
render_input ~label_text:"Test Email Address (optional)"
~name:"to_email" ~id:"to-email" ~input_type:`Text ~value:"" ();
div
~a:
[
a_class [ "my-6 flex mx-4 justify-center px-4" ];
a_style "gap: 1rem";
]
[
Utils.button_component
~attribs:
[ a_id "test-email-btn"; a_onclick "sendTestEmail()" ]
~content:(txt "Send Test Email") ~btn_type:`Primary_outlined
();
Utils.button_component
~attribs:
[
a_id "update-email-config-btn";
a_onclick "updateEmailConfig()";
]
~content:(txt "Update Configuration")
~btn_type:`Primary_full ();
];
];
])