Lines 3-20
Link Here
|
3 |
[% PROCESS 'i18n.inc' %] |
3 |
[% PROCESS 'i18n.inc' %] |
4 |
[% SET footerjs = 1 %] |
4 |
[% SET footerjs = 1 %] |
5 |
[% INCLUDE 'doc-head-open.inc' %] |
5 |
[% INCLUDE 'doc-head-open.inc' %] |
6 |
<title>[% FILTER collapse %] |
6 |
<title |
7 |
[% IF op == 'add_form' %] |
7 |
>[% FILTER collapse %] |
8 |
[% t("New FTP/SFTP server") | html %] › |
8 |
[% IF op == 'add_form' %] |
9 |
[% ELSIF op == 'edit_form' %] |
9 |
[% t("New FTP/SFTP server") | html %] |
10 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] › |
10 |
› |
11 |
[% ELSIF op == 'test_form' %] |
11 |
[% ELSIF op == 'edit_form' %] |
12 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] › |
12 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
13 |
[% END %] |
13 |
› |
14 |
[% t("FTP/SFTP Servers") | html %] › |
14 |
[% ELSIF op == 'test_form' %] |
15 |
[% t("Administration") | html %] › |
15 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
16 |
[% t("Koha") | html %] |
16 |
› |
17 |
[% END %]</title> |
17 |
[% END %] |
|
|
18 |
[% t("FTP/SFTP Servers") | html %] |
19 |
› [% t("Administration") | html %] › [% t("Koha") | html %] |
20 |
[% END %]</title |
21 |
> |
18 |
[% INCLUDE 'doc-head-close.inc' %] |
22 |
[% INCLUDE 'doc-head-close.inc' %] |
19 |
<style> |
23 |
<style> |
20 |
#testOutput { |
24 |
#testOutput { |
Lines 57-73
Link Here
|
57 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
61 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
58 |
<span>New FTP/SFTP server</span> |
62 |
<span>New FTP/SFTP server</span> |
59 |
[% END %] |
63 |
[% END %] |
60 |
|
|
|
61 |
[% ELSIF op == 'edit_form' %] |
64 |
[% ELSIF op == 'edit_form' %] |
62 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
65 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
63 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
66 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
64 |
[% END %] |
67 |
[% END %] |
65 |
|
|
|
66 |
[% ELSIF op == 'test_form' %] |
68 |
[% ELSIF op == 'test_form' %] |
67 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
69 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
68 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
70 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
69 |
[% END %] |
71 |
[% END %] |
70 |
|
|
|
71 |
[% ELSE %] |
72 |
[% ELSE %] |
72 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
73 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
73 |
<span>FTP/SFTP servers</span> |
74 |
<span>FTP/SFTP servers</span> |
Lines 82-963
Link Here
|
82 |
<main> |
83 |
<main> |
83 |
[% INCLUDE 'messages.inc' %] |
84 |
[% INCLUDE 'messages.inc' %] |
84 |
|
85 |
|
85 |
[% FOREACH m IN messages %] |
86 |
[% FOREACH m IN messages %] |
86 |
<div class="alert alert-[% m.type | html %]" id="sftp_action_result_dialog"> |
87 |
<div class="alert alert-[% m.type | html %]" id="sftp_action_result_dialog"> |
87 |
[% SWITCH m.code %] |
88 |
[% SWITCH m.code %] |
88 |
[% CASE 'error_on_insert' %] |
89 |
[% CASE 'error_on_insert' %] |
89 |
<span>An error occurred when adding the server. The passed ID already exists.</span> |
90 |
<span>An error occurred when adding the server. The passed ID already exists.</span> |
90 |
[% CASE 'error_on_update' %] |
91 |
[% CASE 'error_on_update' %] |
91 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
92 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
92 |
[% CASE 'error_on_edit' %] |
93 |
[% CASE 'error_on_edit' %] |
93 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
94 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
94 |
[% CASE 'error_on_test' %] |
95 |
[% CASE 'error_on_test' %] |
95 |
<span>An error occurred when connecting to this server. Please see the text below for more information.</span> |
96 |
<span>An error occurred when connecting to this server. Please see the text below for more information.</span> |
96 |
[% CASE 'success_on_update' %] |
97 |
[% CASE 'success_on_update' %] |
97 |
<span>Server updated successfully.</span> |
98 |
<span>Server updated successfully.</span> |
98 |
[% CASE 'success_on_insert' %] |
99 |
[% CASE 'success_on_insert' %] |
99 |
<span>Server added successfully.</span> |
100 |
<span>Server added successfully.</span> |
100 |
[% CASE %] |
101 |
[% CASE %] |
101 |
<span>[% m.code | html %]</span> |
102 |
<span>[% m.code | html %]</span> |
102 |
[% END %] |
103 |
[% END %] |
103 |
</div> |
|
|
104 |
[% END %] |
105 |
|
106 |
<div class="alert alert-info" id="sftp_delete_success" style="display: none;"></div> |
107 |
<div class="alert alert-warning" id="sftp_delete_error" style="display: none;"></div> |
108 |
|
109 |
[% IF op == 'add_form' %] |
110 |
<!-- Modal --> |
111 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
112 |
<div class="modal-dialog modal-lg"> |
113 |
<div class="modal-content modal-lg"> |
114 |
<div class="modal-header"> |
115 |
<h1 class="modal-title">Are you sure?</h1> |
116 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
117 |
</div> |
104 |
</div> |
118 |
<div class="modal-body"> |
105 |
[% END %] |
119 |
<div id="modal_message" class="alert alert-warning">Because you are using the SFTP transport, please run a test of this connection to accept the server's host key.</div> |
106 |
|
120 |
<p>Before saving, please check the following details again to make sure you are certain they are correct. Sending or receiving data from an unknown source potentially puts your system at risk.</p> |
107 |
<div class="alert alert-info" id="sftp_delete_success" style="display: none;"></div> |
121 |
<table class="mx-4 mb-3"> |
108 |
<div class="alert alert-warning" id="sftp_delete_error" style="display: none;"></div> |
122 |
<thead></thead> |
109 |
|
123 |
<tbody> |
110 |
[% IF op == 'add_form' %] |
124 |
<tr> |
111 |
<!-- Modal --> |
125 |
<td><strong>Host</strong></td> |
112 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
126 |
<td id="modal_host"></td> |
113 |
<div class="modal-dialog modal-lg"> |
127 |
</tr> |
114 |
<div class="modal-content modal-lg"> |
128 |
<tr> |
115 |
<div class="modal-header"> |
129 |
<td><strong>Port</strong></td> |
116 |
<h1 class="modal-title">Are you sure?</h1> |
130 |
<td id="modal_port"></td> |
117 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
131 |
</tr> |
118 |
</div> |
132 |
<tr> |
119 |
<div class="modal-body"> |
133 |
<td><strong>Transport</strong></td> |
120 |
<div id="modal_message" class="alert alert-warning">Because you are using the SFTP transport, please run a test of this connection to accept the server's host key.</div> |
134 |
<td id="modal_transport"></td> |
121 |
<p>Before saving, please check the following details again to make sure you are certain they are correct. Sending or receiving data from an unknown source potentially puts your system at risk.</p> |
135 |
</tr> |
122 |
<table class="mx-4 mb-3"> |
136 |
<tr> |
123 |
<thead></thead> |
137 |
<td><strong>Username</strong></td> |
124 |
<tbody> |
138 |
<td id="modal_user_name"></td> |
125 |
<tr> |
139 |
</tr> |
126 |
<td><strong>Host</strong></td> |
140 |
<tr> |
127 |
<td id="modal_host"></td> |
141 |
<td><strong>Authentication mode</strong></td> |
128 |
</tr> |
142 |
<td id="modal_auth_mode"></td> |
129 |
<tr> |
143 |
</tr> |
130 |
<td><strong>Port</strong></td> |
144 |
</tbody> |
131 |
<td id="modal_port"></td> |
145 |
</table> |
132 |
</tr> |
146 |
<p>If you are ready to progress with these details, please click Save.</p> |
133 |
<tr> |
|
|
134 |
<td><strong>Transport</strong></td> |
135 |
<td id="modal_transport"></td> |
136 |
</tr> |
137 |
<tr> |
138 |
<td><strong>Username</strong></td> |
139 |
<td id="modal_user_name"></td> |
140 |
</tr> |
141 |
<tr> |
142 |
<td><strong>Authentication mode</strong></td> |
143 |
<td id="modal_auth_mode"></td> |
144 |
</tr> |
145 |
</tbody> |
146 |
</table> |
147 |
<p>If you are ready to progress with these details, please click Save.</p> |
148 |
</div> |
149 |
<div class="modal-footer"> |
150 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
151 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
152 |
</div> |
153 |
</div> |
154 |
</div> |
147 |
</div> |
155 |
</div> |
148 |
<div class="modal-footer"> |
156 |
<!-- END Modal --> |
149 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
157 |
|
150 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
158 |
<h1>New FTP/SFTP server</h1> |
|
|
159 |
|
160 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="add" name="add" class="validated" method="post"> |
161 |
[% INCLUDE 'csrf-token.inc' %] |
162 |
<input type="hidden" name="op" value="cud-add" /> |
163 |
<fieldset class="rows"> |
164 |
<ol> |
165 |
<li> |
166 |
<label for="sftp_name" class="required">Name: </label> |
167 |
<input type="text" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
168 |
<span class="required">Required</span> |
169 |
</li> |
170 |
</ol> |
171 |
</fieldset> |
172 |
|
173 |
<fieldset class="rows"> |
174 |
<ol> |
175 |
<li> |
176 |
<label for="sftp_host" class="required">Host: </label> |
177 |
<input type="text" value="localhost" name="sftp_host" id="sftp_host" size="60" class="required" /> |
178 |
<span class="required">Required</span> |
179 |
</li> |
180 |
<li> |
181 |
<label for="sftp_port" class="required">Port: </label> |
182 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="22" name="sftp_port" id="sftp_port" size="20" class="required" /> |
183 |
<span class="required">Required</span> |
184 |
</li> |
185 |
<li> |
186 |
<label for="sftp_transport" class="required">Transport: </label> |
187 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
188 |
<option value="ftp">FTP</option> |
189 |
<option value="sftp" selected="selected">SFTP</option> |
190 |
</select> |
191 |
<span class="required">Required</span> |
192 |
</li> |
193 |
<li> |
194 |
<label for="sftp_passive">Passive mode: </label> |
195 |
<select name="sftp_passive" id="sftp_passive" disabled="disabled"> |
196 |
<option value="1" selected="selected">On (Recommended)</option> |
197 |
<option value="0">Off</option> |
198 |
</select> |
199 |
<span class="hint">Only applies to FTP connections</span> |
200 |
</li> |
201 |
<li> |
202 |
<label for="sftp_auth_mode">Authentication mode: </label> |
203 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
204 |
<option value="password" selected="selected">Password-based</option> |
205 |
<option value="key_file">Key file-based</option> |
206 |
<option value="noauth">No authentication</option> |
207 |
</select> |
208 |
</li> |
209 |
<li> |
210 |
<label for="sftp_user_name" class="required">Username: </label> |
211 |
<input type="text" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
212 |
<span class="required">Required</span> |
213 |
</li> |
214 |
<li> |
215 |
<label for="sftp_password">Password: </label> |
216 |
<input type="password" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
217 |
</li> |
218 |
<li> |
219 |
<label for="sftp_key_file">Key file: </label> |
220 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58"></textarea> |
221 |
<span class="hint">Only applies to SFTP connections</span> |
222 |
</li> |
223 |
<li> |
224 |
<label for="sftp_download_directory">Remote download directory: </label> |
225 |
<input type="text" name="sftp_download_directory" id="sftp_download_directory" size="60" autocomplete="off" /><br /> |
226 |
<span class="hint">The path on the remote server where we will download from</span> |
227 |
</li> |
228 |
<li> |
229 |
<label for="sftp_upload_directory">Remote upload directory: </label> |
230 |
<input type="text" name="sftp_upload_directory" id="sftp_upload_directory" size="60" autocomplete="off" /><br /> |
231 |
<span class="hint">The path on the remote server where we will upload to</span> |
232 |
</li> |
233 |
<input type="hidden" value="" name="sftp_status" id="sftp_status" /> |
234 |
<li> |
235 |
<label for="sftp_debug_mode">Debug mode: </label> |
236 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
237 |
<option value="1">Enabled</option> |
238 |
<option value="0" selected="selected">Disabled</option> |
239 |
</select> |
240 |
<span class="hint">Enables additional debug output in the logs</span> |
241 |
</li> |
242 |
</ol> |
243 |
</fieldset> |
244 |
<fieldset class="action"> |
245 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
246 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
247 |
</fieldset> |
248 |
</form> |
249 |
[% END %] |
250 |
|
251 |
[% IF op == 'edit_form' && !messages %] |
252 |
<!-- Modal --> |
253 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
254 |
<div class="modal-dialog modal-lg"> |
255 |
<div class="modal-content modal-lg"> |
256 |
<div class="modal-header"> |
257 |
<h1 class="modal-title">Are you sure?</h1> |
258 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
259 |
</div> |
260 |
<div class="modal-body"> |
261 |
<div id="modal_message" class="alert alert-warning">Because you are using the SFTP transport, please run a test of this connection to accept the server's host key.</div> |
262 |
<p>Before saving, please check the following details again to make sure you are certain they are correct. Sending or receiving data from an unknown source potentially puts your system at risk.</p> |
263 |
<table class="mx-4 mb-3"> |
264 |
<thead></thead> |
265 |
<tbody> |
266 |
<tr> |
267 |
<td><strong>Host</strong></td> |
268 |
<td id="modal_host"></td> |
269 |
</tr> |
270 |
<tr> |
271 |
<td><strong>Port</strong></td> |
272 |
<td id="modal_port"></td> |
273 |
</tr> |
274 |
<tr> |
275 |
<td><strong>Transport</strong></td> |
276 |
<td id="modal_transport"></td> |
277 |
</tr> |
278 |
<tr> |
279 |
<td><strong>Username</strong></td> |
280 |
<td id="modal_user_name"></td> |
281 |
</tr> |
282 |
<tr> |
283 |
<td><strong>Authentication mode</strong></td> |
284 |
<td id="modal_auth_mode"></td> |
285 |
</tr> |
286 |
</tbody> |
287 |
</table> |
288 |
<p>If you are ready to progress with these details, please click Save.</p> |
289 |
</div> |
290 |
<div class="modal-footer"> |
291 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
292 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
293 |
</div> |
294 |
</div> |
295 |
</div> |
151 |
</div> |
296 |
</div> |
152 |
</form> |
297 |
<!-- END Modal --> |
153 |
</div> |
298 |
|
154 |
</div> |
299 |
<h1>[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
155 |
</div> |
300 |
|
156 |
<!-- END Modal --> |
301 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
157 |
|
302 |
[% INCLUDE 'csrf-token.inc' %] |
158 |
<h1>New FTP/SFTP server</h1> |
303 |
<input type="hidden" name="op" value="cud-edit_save" /> |
159 |
|
304 |
<input type="hidden" name="sftp_server_id" value="[%- sftp_server.id | html -%]" /> |
160 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="add" name="add" class="validated" method="post"> |
305 |
<fieldset class="rows"> |
161 |
[% INCLUDE 'csrf-token.inc' %] |
306 |
<ol> |
162 |
<input type="hidden" name="op" value="cud-add" /> |
307 |
<li> |
163 |
<fieldset class="rows"> |
308 |
<label for="sftp_name" class="required">Name: </label> |
164 |
<ol> |
309 |
<input type="text" value="[% sftp_server.name | html %]" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
165 |
<li> |
310 |
<span class="required">Required</span> |
166 |
<label for="sftp_name" class="required">Name: </label> |
311 |
</li> |
167 |
<input type="text" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
312 |
</ol> |
168 |
<span class="required">Required</span> |
313 |
</fieldset> |
169 |
</li> |
314 |
|
170 |
</ol> |
315 |
<fieldset class="rows"> |
171 |
</fieldset> |
316 |
<ol> |
172 |
|
317 |
<li> |
173 |
<fieldset class="rows"> |
318 |
<label for="sftp_host" class="required">Host: </label> |
174 |
<ol> |
319 |
<input type="text" value="[% sftp_server.host | html %]" name="sftp_host" id="sftp_host" size="60" class="required" /> |
175 |
<li> |
320 |
<span class="required">Required</span> |
176 |
<label for="sftp_host" class="required">Host: </label> |
321 |
</li> |
177 |
<input type="text" value="localhost" name="sftp_host" id="sftp_host" size="60" class="required" /> |
322 |
<li> |
178 |
<span class="required">Required</span> |
323 |
<label for="sftp_port" class="required">Port: </label> |
179 |
</li> |
324 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="[% sftp_server.port | html %]" name="sftp_port" id="sftp_port" size="20" class="required" /> |
180 |
<li> |
325 |
<span class="required">Required</span> |
181 |
<label for="sftp_port" class="required">Port: </label> |
326 |
</li> |
182 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="22" name="sftp_port" id="sftp_port" size="20" class="required" /> |
327 |
<li> |
183 |
<span class="required">Required</span> |
328 |
<label for="sftp_transport" class="required">Transport: </label> |
184 |
</li> |
329 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
185 |
<li> |
330 |
[% IF sftp_server.transport == 'ftp' %] |
186 |
<label for="sftp_transport" class="required">Transport: </label> |
331 |
<option value="ftp" selected="selected">FTP</option> |
187 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
332 |
[% ELSE %] |
188 |
<option value="ftp">FTP</option> |
333 |
<option value="ftp">FTP</option> |
189 |
<option value="sftp" selected="selected">SFTP</option> |
334 |
[% END %] |
190 |
</select> |
335 |
[% IF sftp_server.transport == 'sftp' %] |
191 |
<span class="required">Required</span> |
336 |
<option value="sftp" selected="selected">SFTP</option> |
192 |
</li> |
337 |
[% ELSE %] |
193 |
<li> |
338 |
<option value="sftp">SFTP</option> |
194 |
<label for="sftp_passive">Passive mode: </label> |
339 |
[% END %] |
195 |
<select name="sftp_passive" id="sftp_passive" disabled="disabled"> |
340 |
</select> |
196 |
<option value="1" selected="selected">On (Recommended)</option> |
341 |
<span class="required">Required</span> |
197 |
<option value="0">Off</option> |
342 |
</li> |
198 |
</select> |
343 |
<li> |
199 |
<span class="hint">Only applies to FTP connections</span> |
344 |
<label for="sftp_passive">Passive mode: </label> |
200 |
</li> |
345 |
<select name="sftp_passive" id="sftp_passive" disabled="disabled"> |
201 |
<li> |
346 |
[% IF sftp_server.passive == 1 %] |
202 |
<label for="sftp_auth_mode">Authentication mode: </label> |
347 |
<option value="1" selected="selected">Enabled (Recommended)</option> |
203 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
348 |
[% ELSE %] |
204 |
<option value="password" selected="selected">Password-based</option> |
349 |
<option value="1">Enabled (Recommended)</option> |
205 |
<option value="key_file">Key file-based</option> |
350 |
[% END %] |
206 |
<option value="noauth">No authentication</option> |
351 |
[% IF sftp_server.passive == 0 %] |
207 |
</select> |
352 |
<option value="0" selected="selected">Disabled</option> |
208 |
</li> |
353 |
[% ELSE %] |
209 |
<li> |
354 |
<option value="0">Disabled</option> |
210 |
<label for="sftp_user_name" class="required">Username: </label> |
355 |
[% END %] |
211 |
<input type="text" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
356 |
</select> |
212 |
<span class="required">Required</span> |
357 |
<span class="hint">Only applies to FTP connections</span> |
213 |
</li> |
358 |
</li> |
214 |
<li> |
359 |
<li> |
215 |
<label for="sftp_password">Password: </label> |
360 |
<label for="sftp_auth_mode">Authentication mode: </label> |
216 |
<input type="password" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
361 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
217 |
</li> |
362 |
[% IF sftp_server.auth_mode == 'password' %] |
218 |
<li> |
363 |
<option value="password" selected="selected">Password-based</option> |
219 |
<label for="sftp_key_file">Key file: </label> |
364 |
[% ELSE %] |
220 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58"></textarea> |
365 |
<option value="password">Password-based</option> |
221 |
<span class="hint">Only applies to SFTP connections</span> |
366 |
[% END %] |
222 |
</li> |
367 |
[% IF sftp_server.auth_mode == 'key_file' %] |
223 |
<li> |
368 |
<option value="key_file" selected="selected">Key file-based</option> |
224 |
<label for="sftp_download_directory" >Remote download directory: </label> |
369 |
[% ELSE %] |
225 |
<input type="text" name="sftp_download_directory" id="sftp_download_directory" size="60" autocomplete="off" /><br /> |
370 |
<option value="key_file">Key file-based</option> |
226 |
<span class="hint">The path on the remote server where we will download from</span> |
371 |
[% END %] |
227 |
</li> |
372 |
[% IF sftp_server.auth_mode == 'noauth' %] |
228 |
<li> |
373 |
<option value="noauth" selected="selected">No authentication</option> |
229 |
<label for="sftp_upload_directory" >Remote upload directory: </label> |
374 |
[% ELSE %] |
230 |
<input type="text" name="sftp_upload_directory" id="sftp_upload_directory" size="60" autocomplete="off" /><br /> |
375 |
<option value="noauth">No authentication</option> |
231 |
<span class="hint">The path on the remote server where we will upload to</span> |
376 |
[% END %] |
232 |
</li> |
377 |
</select> |
233 |
<input type="hidden" value="" name="sftp_status" id="sftp_status"> |
378 |
</li> |
234 |
<li> |
379 |
<li> |
235 |
<label for="sftp_debug_mode">Debug mode: </label> |
380 |
<label for="sftp_user_name" class="required">Username: </label> |
236 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
381 |
<input type="text" value="[% sftp_server.user_name | html %]" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
237 |
<option value="1">Enabled</option> |
382 |
<span class="required">Required</span> |
238 |
<option value="0" selected="selected">Disabled</option> |
383 |
</li> |
239 |
</select> |
384 |
<li> |
240 |
<span class="hint">Enables additional debug output in the logs</span> |
385 |
<label for="sftp_password">Password: </label> |
241 |
</li> |
386 |
<input type="password" value="[% sftp_server_plain_text_password | html %]" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
242 |
</ol> |
387 |
</li> |
243 |
</fieldset> |
388 |
<li> |
244 |
<fieldset class="action"> |
389 |
<label for="sftp_key_file">Key file path: </label> |
245 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
390 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58">[% sftp_server_plain_text_key | html %]</textarea> |
246 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
391 |
<span class="hint">Only applies to SFTP connections</span> |
247 |
</fieldset> |
392 |
</li> |
248 |
</form> |
393 |
<li> |
249 |
[% END %] |
394 |
<label for="sftp_download_directory">Remote download directory: </label> |
|
|
395 |
<input type="text" value="[% sftp_server.download_directory | html %]" name="sftp_download_directory" id="sftp_download_directory" size="60" autocomplete="off" /><br /> |
396 |
<span class="hint">The path on the remote server where we will download from</span> |
397 |
</li> |
398 |
<li> |
399 |
<label for="sftp_upload_directory">Remote upload directory: </label> |
400 |
<input type="text" value="[% sftp_server.upload_directory | html %]" name="sftp_upload_directory" id="sftp_upload_directory" size="60" autocomplete="off" /><br /> |
401 |
<span class="hint">The path on the remote server where we will upload to</span> |
402 |
</li> |
403 |
<input type="hidden" value="" name="sftp_status" id="sftp_status" /> |
404 |
<li> |
405 |
<label for="sftp_debug_mode">Debug mode: </label> |
406 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
407 |
[% IF sftp_server.debug == 1 %] |
408 |
<option value="1" selected="selected">Enabled</option> |
409 |
[% ELSE %] |
410 |
<option value="1">Enabled</option> |
411 |
[% END %] |
412 |
[% IF sftp_server.debug == 0 %] |
413 |
<option value="0" selected="selected">Disabled</option> |
414 |
[% ELSE %] |
415 |
<option value="0">Disabled</option> |
416 |
[% END %] |
417 |
</select> |
418 |
<span class="hint">Enables additional debug output in the logs</span> |
419 |
</li> |
420 |
</ol> |
421 |
</fieldset> |
422 |
<fieldset class="action"> |
423 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
424 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
425 |
</fieldset> |
426 |
</form> |
427 |
[% END %] |
428 |
|
429 |
[% IF op == 'test_form' %] |
430 |
<h1>[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
431 |
[% IF sftp_server.id %] |
432 |
<div class="page-section"> |
433 |
[% IF sftp_server.transport == 'sftp' %] |
434 |
<div class="alert alert-warning"> |
435 |
<strong>For your information:</strong> As the transport in use for this server is SFTP, please be aware that running a test attempt will also accept the current host key fingerprint of the destination |
436 |
server. If you have doubts about the authenticity of this server, remove its host key from your authorized_keys file immediately, and contact your System Administrator. |
437 |
</div> |
438 |
[% END %] |
439 |
<div class="row"> |
440 |
<div class="col-12 col-lg-6 order-1 order-lg-0"> |
441 |
<h3>Test results</h3> |
442 |
<div id="testOutput"> |
443 |
<!-- tests will appear here --> |
444 |
</div> |
445 |
</div> |
446 |
<div class="col-12 col-lg-6 order-0 order-lg-1"> |
447 |
<h3>Test details</h3> |
448 |
<p>Connection details are as follows:</p> |
449 |
<table class="mx-4 mb-3"> |
450 |
<thead></thead> |
451 |
<tbody> |
452 |
<tr> |
453 |
<td><strong>Host</strong></td> |
454 |
<td>[% sftp_server.host | html %]</td> |
455 |
</tr> |
456 |
<tr> |
457 |
<td><strong>Port</strong></td> |
458 |
<td>[% sftp_server.port | html %]</td> |
459 |
</tr> |
460 |
<tr> |
461 |
<td><strong>Transport</strong></td> |
462 |
<td>[% sftp_server.transport FILTER upper | html %]</td> |
463 |
</tr> |
464 |
<tr> |
465 |
<td><strong>Username</strong></td> |
466 |
<td>[% sftp_server.user_name | html %]</td> |
467 |
</tr> |
468 |
<tr> |
469 |
<td><strong>Authentication mode</strong></td> |
470 |
<td> |
471 |
[% IF sftp_server.auth_mode == 'password' %] |
472 |
Password-based |
473 |
[% ELSE %] |
474 |
Key file-based |
475 |
[% END %] |
476 |
</td> |
477 |
</tr> |
478 |
<tr> |
479 |
<td><strong>Status</strong></td> |
480 |
<td> |
481 |
[% SWITCH sftp_server.status %] |
482 |
[% CASE 'tests_ok' %] |
483 |
Tests passing |
484 |
[% CASE 'tests_failed' %] |
485 |
Tests failing |
486 |
[% CASE %] |
487 |
<em>Never used</em> |
488 |
[% END %] |
489 |
</td> |
490 |
</tr> |
491 |
</tbody> |
492 |
</table> |
493 |
</div> |
494 |
</div> |
495 |
</div> |
496 |
<fieldset class="action"> |
497 |
<a href="/cgi-bin/koha/admin/sftp_servers.pl?op=edit_form&sftp_server_id=[% sftp_server.id | uri %]" class="btn btn-primary"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> |
498 |
<a href="/cgi-bin/koha/admin/sftp_servers.pl?op=test_form&sftp_server_id=[% sftp_server.id | uri %]" class="cancel">Reset</a> |
499 |
</fieldset> |
500 |
[% ELSE %] |
501 |
<div class="page-section"> |
502 |
<h3>Oops – Not Found</h3> |
503 |
<p>An FTP/SFTP server with that ID was not found. Please go back and try again.</p> |
504 |
</div> |
505 |
[% END %] |
506 |
[% END %] |
250 |
|
507 |
|
251 |
[% IF op == 'edit_form' && !messages %] |
508 |
[% IF op == 'list' %] |
252 |
<!-- Modal --> |
509 |
<div id="toolbar" class="btn-toolbar"> |
253 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
510 |
<a class="btn btn-default" id="new_sftp_server" href="/cgi-bin/koha/admin/sftp_servers.pl?op=add_form"><i class="fa fa-plus"></i> New FTP/SFTP server</a> |
254 |
<div class="modal-dialog modal-lg"> |
|
|
255 |
<div class="modal-content modal-lg"> |
256 |
<div class="modal-header"> |
257 |
<h1 class="modal-title">Are you sure?</h1> |
258 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
259 |
</div> |
260 |
<div class="modal-body"> |
261 |
<div id="modal_message" class="alert alert-warning">Because you are using the SFTP transport, please run a test of this connection to accept the server's host key.</div> |
262 |
<p>Before saving, please check the following details again to make sure you are certain they are correct. Sending or receiving data from an unknown source potentially puts your system at risk.</p> |
263 |
<table class="mx-4 mb-3"> |
264 |
<thead></thead> |
265 |
<tbody> |
266 |
<tr> |
267 |
<td><strong>Host</strong></td> |
268 |
<td id="modal_host"></td> |
269 |
</tr> |
270 |
<tr> |
271 |
<td><strong>Port</strong></td> |
272 |
<td id="modal_port"></td> |
273 |
</tr> |
274 |
<tr> |
275 |
<td><strong>Transport</strong></td> |
276 |
<td id="modal_transport"></td> |
277 |
</tr> |
278 |
<tr> |
279 |
<td><strong>Username</strong></td> |
280 |
<td id="modal_user_name"></td> |
281 |
</tr> |
282 |
<tr> |
283 |
<td><strong>Authentication mode</strong></td> |
284 |
<td id="modal_auth_mode"></td> |
285 |
</tr> |
286 |
</tbody> |
287 |
</table> |
288 |
<p>If you are ready to progress with these details, please click Save.</p> |
289 |
</div> |
290 |
<div class="modal-footer"> |
291 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
292 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
293 |
</div> |
511 |
</div> |
294 |
</form> |
|
|
295 |
</div> |
296 |
</div> |
297 |
</div> |
298 |
<!-- END Modal --> |
299 |
|
300 |
<h1>[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
301 |
|
302 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
303 |
[% INCLUDE 'csrf-token.inc' %] |
304 |
<input type="hidden" name="op" value="cud-edit_save" /> |
305 |
<input type="hidden" name="sftp_server_id" value="[%- sftp_server.id | html -%]" /> |
306 |
<fieldset class="rows"> |
307 |
<ol> |
308 |
<li> |
309 |
<label for="sftp_name" class="required">Name: </label> |
310 |
<input type="text" value="[% sftp_server.name | html %]" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
311 |
<span class="required">Required</span> |
312 |
</li> |
313 |
</ol> |
314 |
</fieldset> |
315 |
|
316 |
<fieldset class="rows"> |
317 |
<ol> |
318 |
<li> |
319 |
<label for="sftp_host" class="required">Host: </label> |
320 |
<input type="text" value="[% sftp_server.host | html %]" name="sftp_host" id="sftp_host" size="60" class="required" /> |
321 |
<span class="required">Required</span> |
322 |
</li> |
323 |
<li> |
324 |
<label for="sftp_port" class="required">Port: </label> |
325 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="[% sftp_server.port | html %]" name="sftp_port" id="sftp_port" size="20" class="required"/> |
326 |
<span class="required">Required</span> |
327 |
</li> |
328 |
<li> |
329 |
<label for="sftp_transport" class="required">Transport: </label> |
330 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
331 |
[% IF sftp_server.transport == 'ftp' %] |
332 |
<option value="ftp" selected="selected">FTP</option> |
333 |
[% ELSE %] |
334 |
<option value="ftp">FTP</option> |
335 |
[% END %] |
336 |
[% IF sftp_server.transport == 'sftp' %] |
337 |
<option value="sftp" selected="selected">SFTP</option> |
338 |
[% ELSE %] |
339 |
<option value="sftp">SFTP</option> |
340 |
[% END %] |
341 |
</select> |
342 |
<span class="required">Required</span> |
343 |
</li> |
344 |
<li> |
345 |
<label for="sftp_passive">Passive mode: </label> |
346 |
<select name="sftp_passive" id="sftp_passive" disabled="disabled"> |
347 |
[% IF sftp_server.passive == 1 %] |
348 |
<option value="1" selected="selected">Enabled (Recommended)</option> |
349 |
[% ELSE %] |
350 |
<option value="1">Enabled (Recommended)</option> |
351 |
[% END %] |
352 |
[% IF sftp_server.passive == 0 %] |
353 |
<option value="0" selected="selected">Disabled</option> |
354 |
[% ELSE %] |
355 |
<option value="0">Disabled</option> |
356 |
[% END %] |
357 |
</select> |
358 |
<span class="hint">Only applies to FTP connections</span> |
359 |
</li> |
360 |
<li> |
361 |
<label for="sftp_auth_mode">Authentication mode: </label> |
362 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
363 |
[% IF sftp_server.auth_mode == 'password' %] |
364 |
<option value="password" selected="selected">Password-based</option> |
365 |
[% ELSE %] |
366 |
<option value="password">Password-based</option> |
367 |
[% END %] |
368 |
[% IF sftp_server.auth_mode == 'key_file' %] |
369 |
<option value="key_file" selected="selected">Key file-based</option> |
370 |
[% ELSE %] |
371 |
<option value="key_file">Key file-based</option> |
372 |
[% END %] |
373 |
[% IF sftp_server.auth_mode == 'noauth' %] |
374 |
<option value="noauth" selected="selected">No authentication</option> |
375 |
[% ELSE %] |
376 |
<option value="noauth">No authentication</option> |
377 |
[% END %] |
378 |
</select> |
379 |
</li> |
380 |
<li> |
381 |
<label for="sftp_user_name" class="required">Username: </label> |
382 |
<input type="text" value="[% sftp_server.user_name | html %]" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
383 |
<span class="required">Required</span> |
384 |
</li> |
385 |
<li> |
386 |
<label for="sftp_password">Password: </label> |
387 |
<input type="password" value="[% sftp_server_plain_text_password | html %]" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
388 |
</li> |
389 |
<li> |
390 |
<label for="sftp_key_file">Key file path: </label> |
391 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58">[% sftp_server_plain_text_key | html %]</textarea> |
392 |
<span class="hint">Only applies to SFTP connections</span> |
393 |
</li> |
394 |
<li> |
395 |
<label for="sftp_download_directory" >Remote download directory: </label> |
396 |
<input type="text" value="[% sftp_server.download_directory | html %]" name="sftp_download_directory" id="sftp_download_directory" size="60" autocomplete="off" /><br /> |
397 |
<span class="hint">The path on the remote server where we will download from</span> |
398 |
</li> |
399 |
<li> |
400 |
<label for="sftp_upload_directory" >Remote upload directory: </label> |
401 |
<input type="text" value="[% sftp_server.upload_directory | html %]" name="sftp_upload_directory" id="sftp_upload_directory" size="60" autocomplete="off" /><br /> |
402 |
<span class="hint">The path on the remote server where we will upload to</span> |
403 |
</li> |
404 |
<input type="hidden" value="" name="sftp_status" id="sftp_status"> |
405 |
<li> |
406 |
<label for="sftp_debug_mode">Debug mode: </label> |
407 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
408 |
[% IF sftp_server.debug == 1 %] |
409 |
<option value="1" selected="selected">Enabled</option> |
410 |
[% ELSE %] |
411 |
<option value="1">Enabled</option> |
412 |
[% END %] |
413 |
[% IF sftp_server.debug == 0 %] |
414 |
<option value="0" selected="selected">Disabled</option> |
415 |
[% ELSE %] |
416 |
<option value="0">Disabled</option> |
417 |
[% END %] |
418 |
</select> |
419 |
<span class="hint">Enables additional debug output in the logs</span> |
420 |
</li> |
421 |
</ol> |
422 |
</fieldset> |
423 |
<fieldset class="action"> |
424 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
425 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
426 |
</fieldset> |
427 |
</form> |
428 |
[% END %] |
429 |
|
512 |
|
430 |
[% IF op == 'test_form' %] |
513 |
<h1>FTP/SFTP servers</h1> |
431 |
|
514 |
|
432 |
<h1>[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
515 |
[% IF servers_count < 1 %] |
433 |
[% IF sftp_server.id %] |
516 |
<div class="alert alert-info" id="dno_servers_message"> |
434 |
<div class="page-section"> |
517 |
<p> |
435 |
[% IF sftp_server.transport == 'sftp' %] |
518 |
<em>There are no FTP/SFTP servers defined.</em><br /> |
436 |
<div class="alert alert-warning"> |
519 |
To create one, use the <strong>new FTP/SFTP server</strong> button above. |
437 |
<strong>For your information:</strong> As the transport in use for this server is SFTP, please be aware that running a test attempt will also accept the current host key fingerprint of the destination server. If you have doubts about the authenticity of this server, remove its host key from your authorized_keys file immediately, and contact your System Administrator. |
520 |
</p> |
438 |
</div> |
|
|
439 |
[% END %] |
440 |
<div class="row"> |
441 |
<div class="col-12 col-lg-6 order-1 order-lg-0"> |
442 |
<h3>Test results</h3> |
443 |
<div id="testOutput"> |
444 |
<!-- tests will appear here --> |
445 |
</div> |
446 |
</div> |
447 |
<div class="col-12 col-lg-6 order-0 order-lg-1"> |
448 |
<h3>Test details</h3> |
449 |
<p>Connection details are as follows:</p> |
450 |
<table class="mx-4 mb-3"> |
451 |
<thead></thead> |
452 |
<tbody> |
453 |
<tr> |
454 |
<td><strong>Host</strong></td> |
455 |
<td>[% sftp_server.host | html %]</td> |
456 |
</tr> |
457 |
<tr> |
458 |
<td><strong>Port</strong></td> |
459 |
<td>[% sftp_server.port | html %]</td> |
460 |
</tr> |
461 |
<tr> |
462 |
<td><strong>Transport</strong></td> |
463 |
<td>[% sftp_server.transport FILTER upper | html %]</td> |
464 |
</tr> |
465 |
<tr> |
466 |
<td><strong>Username</strong></td> |
467 |
<td>[% sftp_server.user_name | html %]</td> |
468 |
</tr> |
469 |
<tr> |
470 |
<td><strong>Authentication mode</strong></td> |
471 |
<td> |
472 |
[% IF sftp_server.auth_mode == 'password' %] |
473 |
Password-based |
474 |
[% ELSE %] |
475 |
Key file-based |
476 |
[% END %] |
477 |
</td> |
478 |
</tr> |
479 |
<tr> |
480 |
<td><strong>Status</strong></td> |
481 |
<td> |
482 |
[% SWITCH sftp_server.status %] |
483 |
[% CASE 'tests_ok' %] |
484 |
Tests passing |
485 |
[% CASE 'tests_failed' %] |
486 |
Tests failing |
487 |
[% CASE %] |
488 |
<em>Never used</em> |
489 |
[% END %] |
490 |
</td> |
491 |
</tr> |
492 |
</tbody> |
493 |
</table> |
494 |
</div> |
495 |
</div> |
496 |
</div> |
497 |
<fieldset class="action"> |
498 |
<a href="/cgi-bin/koha/admin/sftp_servers.pl?op=edit_form&sftp_server_id=[% sftp_server.id | uri %]" class="btn btn-primary"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> |
499 |
<a href="/cgi-bin/koha/admin/sftp_servers.pl?op=test_form&sftp_server_id=[% sftp_server.id | uri %]" class="cancel">Reset</a> |
500 |
</fieldset> |
501 |
[% ELSE %] |
502 |
<div class="page-section"> |
503 |
<h3>Oops – Not Found</h3> |
504 |
<p>An FTP/SFTP server with that ID was not found. Please go back and try again.</p> |
505 |
</div> |
506 |
[% END %] |
507 |
[% END %] |
508 |
|
509 |
[% IF op == 'list' %] |
510 |
|
511 |
<div id="toolbar" class="btn-toolbar"> |
512 |
<a class="btn btn-default" id="new_sftp_server" href="/cgi-bin/koha/admin/sftp_servers.pl?op=add_form"><i class="fa fa-plus"></i> New FTP/SFTP server</a> |
513 |
</div> |
514 |
|
515 |
<h1>FTP/SFTP servers</h1> |
516 |
|
517 |
[% IF servers_count < 1 %] |
518 |
<div class="alert alert-info" id="dno_servers_message"> |
519 |
<p> |
520 |
<em>There are no FTP/SFTP servers defined.</em><br /> |
521 |
To create one, use the <strong>new FTP/SFTP server</strong> button above. |
522 |
</p> |
523 |
</div> |
524 |
[% ELSE %] |
525 |
<div class="page-section"> |
526 |
<table id="sftp_servers"> |
527 |
<thead> |
528 |
<tr> |
529 |
<th>Name</th> |
530 |
<th>Host</th> |
531 |
<th>Port</th> |
532 |
<th>Transport</th> |
533 |
<th>Authentication mode</th> |
534 |
<th>Username</th> |
535 |
<th>Download directory</th> |
536 |
<th>Upload directory</th> |
537 |
<th>Status</th> |
538 |
<th>Debug</th> |
539 |
<th data-class-name="actions noExport">Actions</th> |
540 |
</tr> |
541 |
</thead> |
542 |
</table> |
543 |
</div> <!-- /.page-section --> |
544 |
[% END %] |
545 |
[% END %] |
546 |
|
547 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
548 |
<div class="modal-dialog"> |
549 |
<div class="modal-content"> |
550 |
<div class="modal-header"> |
551 |
<h1 class="modal-title" id="delete_confirm_modal_label">Delete server</h1> |
552 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
553 |
</div> |
521 |
</div> |
554 |
<div class="modal-body"> |
522 |
[% ELSE %] |
555 |
<div id="delete_confirm_dialog"></div> |
523 |
<div class="page-section"> |
|
|
524 |
<table id="sftp_servers"> |
525 |
<thead> |
526 |
<tr> |
527 |
<th>Name</th> |
528 |
<th>Host</th> |
529 |
<th>Port</th> |
530 |
<th>Transport</th> |
531 |
<th>Authentication mode</th> |
532 |
<th>Username</th> |
533 |
<th>Download directory</th> |
534 |
<th>Upload directory</th> |
535 |
<th>Status</th> |
536 |
<th>Debug</th> |
537 |
<th data-class-name="actions noExport">Actions</th> |
538 |
</tr> |
539 |
</thead> |
540 |
</table> |
556 |
</div> |
541 |
</div> |
557 |
<div class="modal-footer"> |
542 |
<!-- /.page-section --> |
558 |
<button type="button" class="btn btn-danger" id="delete_confirm_modal_button" data-bs-toggle="modal">Delete</button> |
543 |
[% END %] |
559 |
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button> |
544 |
[% END %] |
|
|
545 |
|
546 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
547 |
<div class="modal-dialog"> |
548 |
<div class="modal-content"> |
549 |
<div class="modal-header"> |
550 |
<h1 class="modal-title" id="delete_confirm_modal_label">Delete server</h1> |
551 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
552 |
</div> |
553 |
<div class="modal-body"> |
554 |
<div id="delete_confirm_dialog"></div> |
555 |
</div> |
556 |
<div class="modal-footer"> |
557 |
<button type="button" class="btn btn-danger" id="delete_confirm_modal_button" data-bs-toggle="modal">Delete</button> |
558 |
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button> |
559 |
</div> |
560 |
</div> |
560 |
</div> |
561 |
</div> <!-- /.modal-content --> |
561 |
<!-- /.modal-content --> |
562 |
</div> <!-- /.modal-dialog --> |
562 |
</div> |
563 |
</div> <!-- #delete_confirm_modal --> |
563 |
<!-- /.modal-dialog --> |
564 |
|
564 |
</div> |
|
|
565 |
<!-- #delete_confirm_modal --> |
565 |
</main> |
566 |
</main> |
566 |
</div> <!-- /.col-md-10.order-md-2 --> |
567 |
</div> |
|
|
568 |
<!-- /.col-md-10.order-md-2 --> |
567 |
|
569 |
|
568 |
<div class="col-md-2 order-sm-2 order-md-1"> |
570 |
<div class="col-md-2 order-sm-2 order-md-1"> |
569 |
<aside> |
571 |
<aside> [% INCLUDE 'admin-menu.inc' %] </aside> |
570 |
[% INCLUDE 'admin-menu.inc' %] |
572 |
</div> |
571 |
</aside> |
573 |
<!-- /.col-md-2.order-md-1 --> |
572 |
</div> <!-- /.col-md-2.order-md-1 --> |
574 |
</div> |
573 |
</div> <!-- /.row --> |
575 |
<!-- /.row --> |
574 |
|
576 |
|
575 |
|
577 |
[% MACRO jsinclude BLOCK %] |
576 |
[% MACRO jsinclude BLOCK %] |
578 |
[% Asset.js("js/admin-menu.js") | $raw %] |
577 |
[% Asset.js("js/admin-menu.js") | $raw %] |
579 |
[% INCLUDE 'datatables.inc' %] |
578 |
[% INCLUDE 'datatables.inc' %] |
580 |
<script> |
579 |
<script> |
581 |
$(document).ready(function() { |
580 |
$(document).ready(function() { |
582 |
|
581 |
|
583 |
var sftp_servers_url = '/api/v1/config/sftp_servers'; |
582 |
var sftp_servers_url = '/api/v1/config/sftp_servers'; |
584 |
window.sftp_servers = $("#sftp_servers").kohaTable({ |
583 |
window.sftp_servers = $("#sftp_servers").kohaTable({ |
585 |
"ajax": { |
584 |
"ajax": { |
586 |
"url": sftp_servers_url |
585 |
"url": sftp_servers_url |
|
|
586 |
}, |
587 |
"language": { |
588 |
"emptyTable": "<div class=\"alert alert-info\">"+_("There are no FTP/SFTP servers defined.")+"</div>" |
589 |
}, |
590 |
"columnDefs": [ { |
591 |
"targets": [0,1], |
592 |
"render": function(data, type, row, meta) { |
593 |
if (type == "display") { |
594 |
if(data != null) { |
595 |
return data.escapeHtml(); |
596 |
} else { |
597 |
return "Default"; |
598 |
} |
599 |
} |
600 |
return data; |
601 |
} |
602 |
} ], |
603 |
"columns": [ |
604 |
{ |
605 |
"data": "name", |
606 |
"searchable": true, |
607 |
"orderable": true |
608 |
}, |
609 |
{ |
610 |
"data": "host", |
611 |
"searchable": true, |
612 |
"orderable": true |
613 |
}, |
614 |
{ |
615 |
"data": "port", |
616 |
"searchable": true, |
617 |
"orderable": false |
618 |
}, |
587 |
}, |
619 |
{ |
588 |
"language": { |
620 |
"data": "transport", |
589 |
"emptyTable": "<div class=\"alert alert-info\">"+_("There are no FTP/SFTP servers defined.")+"</div>" |
621 |
"render": function(data, type, row, meta) { |
|
|
622 |
return data.toUpperCase(); |
623 |
}, |
624 |
"searchable": true, |
625 |
"orderable": false |
626 |
}, |
590 |
}, |
627 |
{ |
591 |
"columnDefs": [ { |
628 |
"data": "auth_mode", |
592 |
"targets": [0,1], |
629 |
"render": function(data, type, row, meta) { |
593 |
"render": function(data, type, row, meta) { |
630 |
if(data == "password") { |
594 |
if (type == "display") { |
631 |
return _("Password-based"); |
595 |
if(data != null) { |
632 |
} else if(data == "key_file") { |
596 |
return data.escapeHtml(); |
633 |
return _("Key file-based"); |
597 |
} else { |
634 |
} else { |
598 |
return "Default"; |
635 |
return _("No authentication"); |
599 |
} |
636 |
} |
600 |
} |
|
|
601 |
return data; |
602 |
} |
603 |
} ], |
604 |
"columns": [ |
605 |
{ |
606 |
"data": "name", |
607 |
"searchable": true, |
608 |
"orderable": true |
637 |
}, |
609 |
}, |
638 |
"searchable": false, |
610 |
{ |
639 |
"orderable": false |
611 |
"data": "host", |
640 |
}, |
612 |
"searchable": true, |
641 |
{ |
613 |
"orderable": true |
642 |
"data": "user_name", |
|
|
643 |
"searchable": false, |
644 |
"orderable": false |
645 |
}, |
646 |
{ |
647 |
"data": "download_directory", |
648 |
"render": function(data, type, row, meta) { |
649 |
if(data) { |
650 |
return data; |
651 |
} else { |
652 |
return "<em>" + _("Not specified") + "</em>"; |
653 |
} |
654 |
}, |
614 |
}, |
655 |
"searchable": false, |
615 |
{ |
656 |
"orderable": false |
616 |
"data": "port", |
657 |
}, |
617 |
"searchable": true, |
658 |
{ |
618 |
"orderable": false |
659 |
"data": "upload_directory", |
|
|
660 |
"render": function(data, type, row, meta) { |
661 |
if(data) { |
662 |
return data; |
663 |
} else { |
664 |
return "<em>" + _("Not specified") + "</em>"; |
665 |
} |
666 |
}, |
619 |
}, |
667 |
"searchable": false, |
620 |
{ |
668 |
"orderable": false |
621 |
"data": "transport", |
669 |
}, |
622 |
"render": function(data, type, row, meta) { |
670 |
{ |
623 |
return data.toUpperCase(); |
671 |
"data": "status", |
624 |
}, |
672 |
"render": function(data, type, row, meta) { |
625 |
"searchable": true, |
673 |
if (data == "tests_ok") { |
626 |
"orderable": false |
674 |
return _("Tests passing"); |
|
|
675 |
} else if (data == "tests_failed") { |
676 |
return _("Tests failing"); |
677 |
} else { |
678 |
return "<em>" + _("Never used") + "</em>"; |
679 |
} |
680 |
}, |
627 |
}, |
681 |
"searchable": false, |
628 |
{ |
682 |
"orderable": false |
629 |
"data": "auth_mode", |
683 |
}, |
630 |
"render": function(data, type, row, meta) { |
684 |
{ |
631 |
if(data == "password") { |
685 |
"data": "debug", |
632 |
return _("Password-based"); |
686 |
"render": function(data, type, row, meta) { |
633 |
} else if(data == "key_file") { |
687 |
if(data == true) { |
634 |
return _("Key file-based"); |
688 |
return "[% tp("Active", "On") | html %]"; |
635 |
} else { |
689 |
} |
636 |
return _("No authentication"); |
690 |
else { |
637 |
} |
691 |
return _("Off"); |
638 |
}, |
692 |
} |
639 |
"searchable": false, |
|
|
640 |
"orderable": false |
693 |
}, |
641 |
}, |
694 |
"searchable": false, |
642 |
{ |
695 |
"orderable": false |
643 |
"data": "user_name", |
696 |
}, |
644 |
"searchable": false, |
697 |
{ |
645 |
"orderable": false |
698 |
"data": function(row, type, val, meta) { |
|
|
699 |
var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/sftp_servers.pl?op=test_form&sftp_server_id='+ encodeURIComponent(row.sftp_server_id) +'"><i class="fa-solid fa-vial" aria-hidden="true"></i> '+_("Test")+'</a>'+"\n"; |
700 |
result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/sftp_servers.pl?op=edit_form&sftp_server_id='+ encodeURIComponent(row.sftp_server_id) +'"><i class="fa-solid fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; |
701 |
result += '<a class="btn btn-default btn-xs delete_server" role="button" href="#" data-bs-toggle="modal" data-bs-target="#delete_confirm_modal" data-sftp-server-id="'+ encodeURIComponent(row.sftp_server_id) +'" data-sftp-server-name="'+ encodeURIComponent(row.name.escapeHtml()) +'"><i class="fa fa-trash-can" aria-hidden="true"></i> '+_("Delete")+'</a>'; |
702 |
return result; |
703 |
}, |
646 |
}, |
704 |
"searchable": false, |
647 |
{ |
705 |
"orderable": false |
648 |
"data": "download_directory", |
706 |
} |
649 |
"render": function(data, type, row, meta) { |
707 |
], |
650 |
if(data) { |
708 |
createdRow: function(row, data, dataIndex) { |
651 |
return data; |
709 |
if(data.is_default) { |
652 |
} else { |
710 |
$(row).addClass('default warn'); |
653 |
return "<em>" + _("Not specified") + "</em>"; |
711 |
} |
654 |
} |
712 |
if(data.debug) { |
655 |
}, |
713 |
$(row).addClass('debug'); |
656 |
"searchable": false, |
714 |
} |
657 |
"orderable": false |
715 |
}, |
658 |
}, |
716 |
}); |
659 |
{ |
717 |
|
660 |
"data": "upload_directory", |
718 |
$('#sftp_servers').on("click", '.delete_server', function() { |
661 |
"render": function(data, type, row, meta) { |
719 |
var sftp_server_id = $(this).data('sftp-server-id'); |
662 |
if(data) { |
720 |
var sftp_server_name = decodeURIComponent($(this).data('sftp-server-name')); |
663 |
return data; |
721 |
|
664 |
} else { |
722 |
$("#delete_confirm_dialog").html( |
665 |
return "<em>" + _("Not specified") + "</em>"; |
723 |
_("You are about to delete the '%s' FTP/SFTP server.").format(sftp_server_name) |
666 |
} |
724 |
); |
667 |
}, |
725 |
$("#delete_confirm_modal_button").data('sftp-server-id', sftp_server_id); |
668 |
"searchable": false, |
726 |
$("#delete_confirm_modal_button").data('sftp-server-name', sftp_server_name); |
669 |
"orderable": false |
727 |
}); |
670 |
}, |
|
|
671 |
{ |
672 |
"data": "status", |
673 |
"render": function(data, type, row, meta) { |
674 |
if (data == "tests_ok") { |
675 |
return _("Tests passing"); |
676 |
} else if (data == "tests_failed") { |
677 |
return _("Tests failing"); |
678 |
} else { |
679 |
return "<em>" + _("Never used") + "</em>"; |
680 |
} |
681 |
}, |
682 |
"searchable": false, |
683 |
"orderable": false |
684 |
}, |
685 |
{ |
686 |
"data": "debug", |
687 |
"render": function(data, type, row, meta) { |
688 |
if(data == true) { |
689 |
return "[% tp("Active", "On") | html %]"; |
690 |
} |
691 |
else { |
692 |
return _("Off"); |
693 |
} |
694 |
}, |
695 |
"searchable": false, |
696 |
"orderable": false |
697 |
}, |
698 |
{ |
699 |
"data": function(row, type, val, meta) { |
700 |
var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/sftp_servers.pl?op=test_form&sftp_server_id='+ encodeURIComponent(row.sftp_server_id) +'"><i class="fa-solid fa-vial" aria-hidden="true"></i> '+_("Test")+'</a>'+"\n"; |
701 |
result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/sftp_servers.pl?op=edit_form&sftp_server_id='+ encodeURIComponent(row.sftp_server_id) +'"><i class="fa-solid fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; |
702 |
result += '<a class="btn btn-default btn-xs delete_server" role="button" href="#" data-bs-toggle="modal" data-bs-target="#delete_confirm_modal" data-sftp-server-id="'+ encodeURIComponent(row.sftp_server_id) +'" data-sftp-server-name="'+ encodeURIComponent(row.name.escapeHtml()) +'"><i class="fa fa-trash-can" aria-hidden="true"></i> '+_("Delete")+'</a>'; |
703 |
return result; |
704 |
}, |
705 |
"searchable": false, |
706 |
"orderable": false |
707 |
} |
708 |
], |
709 |
createdRow: function(row, data, dataIndex) { |
710 |
if(data.is_default) { |
711 |
$(row).addClass('default warn'); |
712 |
} |
713 |
if(data.debug) { |
714 |
$(row).addClass('debug'); |
715 |
} |
716 |
}, |
717 |
}); |
728 |
|
718 |
|
729 |
$("#delete_confirm_modal_button").on("click", function() { |
719 |
$('#sftp_servers').on("click", '.delete_server', function() { |
|
|
720 |
var sftp_server_id = $(this).data('sftp-server-id'); |
721 |
var sftp_server_name = decodeURIComponent($(this).data('sftp-server-name')); |
730 |
|
722 |
|
731 |
var sftp_server_id = $(this).data('sftp-server-id'); |
723 |
$("#delete_confirm_dialog").html( |
732 |
var sftp_server_name = $(this).data('sftp-server-name'); |
724 |
_("You are about to delete the '%s' FTP/SFTP server.").format(sftp_server_name) |
|
|
725 |
); |
726 |
$("#delete_confirm_modal_button").data('sftp-server-id', sftp_server_id); |
727 |
$("#delete_confirm_modal_button").data('sftp-server-name', sftp_server_name); |
728 |
}); |
733 |
|
729 |
|
734 |
$.ajax({ |
730 |
$("#delete_confirm_modal_button").on("click", function() { |
735 |
method: "DELETE", |
731 |
|
736 |
url: "/api/v1/config/sftp_servers/"+sftp_server_id |
732 |
var sftp_server_id = $(this).data('sftp-server-id'); |
737 |
}).success(function() { |
733 |
var sftp_server_name = $(this).data('sftp-server-name'); |
738 |
window.sftp_servers.api().ajax.reload(function(data) { |
734 |
|
739 |
$("#sftp_action_result_dialog").hide(); |
735 |
$.ajax({ |
740 |
$("#sftp_delete_success").html(_("Server '%s' deleted successfully.").format(sftp_server_name)).show(); |
736 |
method: "DELETE", |
|
|
737 |
url: "/api/v1/config/sftp_servers/"+sftp_server_id |
738 |
}).success(function() { |
739 |
window.sftp_servers.api().ajax.reload(function(data) { |
740 |
$("#sftp_action_result_dialog").hide(); |
741 |
$("#sftp_delete_success").html(_("Server '%s' deleted successfully.").format(sftp_server_name)).show(); |
742 |
}); |
743 |
}).fail(function() { |
744 |
$("#sftp_delete_error").html(_("Error deleting server '%s'. Please ensure all linked EDI accounts are unlinked or deleted. Check the logs for details.").format(sftp_server_name)).show(); |
745 |
}).done(function() { |
746 |
$("#delete_confirm_modal").modal('hide'); |
741 |
}); |
747 |
}); |
742 |
}).fail(function() { |
|
|
743 |
$("#sftp_delete_error").html(_("Error deleting server '%s'. Please ensure all linked EDI accounts are unlinked or deleted. Check the logs for details.").format(sftp_server_name)).show(); |
744 |
}).done(function() { |
745 |
$("#delete_confirm_modal").modal('hide'); |
746 |
}); |
748 |
}); |
747 |
}); |
|
|
748 |
|
749 |
|
749 |
transportChange(); |
|
|
750 |
$("#sftp_transport").on("change", function(event) { |
751 |
transportChange(); |
750 |
transportChange(); |
752 |
}); |
751 |
$("#sftp_transport").on("change", function(event) { |
|
|
752 |
transportChange(); |
753 |
}); |
753 |
|
754 |
|
754 |
authModeChange(); |
|
|
755 |
$("#sftp_auth_mode").on("change", function(event) { |
756 |
authModeChange(); |
755 |
authModeChange(); |
757 |
}); |
756 |
$("#sftp_auth_mode").on("change", function(event) { |
|
|
757 |
authModeChange(); |
758 |
}); |
758 |
|
759 |
|
759 |
$('#confirm_key_accept_submit').on('click', function(event) { |
760 |
$('#confirm_key_accept_submit').on('click', function(event) { |
760 |
event.preventDefault(); |
761 |
event.preventDefault(); |
761 |
|
762 |
|
762 |
if ( $('#add').length > 0 ) { |
763 |
if ( $('#add').length > 0 ) { |
763 |
if( $('#add').valid() == true ) { |
764 |
if( $('#add').valid() == true ) { |
764 |
modalChange(); |
765 |
modalChange(); |
765 |
$('#confirm_key_accept').modal('show'); |
766 |
$('#confirm_key_accept').modal('show'); |
766 |
} else { |
767 |
} else { |
767 |
$('#confirm_key_accept').modal('hide'); |
768 |
$('#confirm_key_accept').modal('hide'); |
|
|
769 |
} |
768 |
} |
770 |
} |
769 |
} |
|
|
770 |
|
771 |
|
771 |
if ( $('#edit_save').length > 0 ) { |
772 |
if ( $('#edit_save').length > 0 ) { |
772 |
if( $('#edit_save').valid() == true ) { |
773 |
if( $('#edit_save').valid() == true ) { |
773 |
modalChange(); |
774 |
modalChange(); |
774 |
$('#confirm_key_accept').modal('show'); |
775 |
$('#confirm_key_accept').modal('show'); |
775 |
} else { |
776 |
} else { |
776 |
$('#confirm_key_accept').modal('hide'); |
777 |
$('#confirm_key_accept').modal('hide'); |
|
|
778 |
} |
777 |
} |
779 |
} |
778 |
} |
|
|
779 |
|
780 |
|
780 |
}); |
781 |
}); |
781 |
|
782 |
|
782 |
$('#confirm_key_accept .approve').on('click', function() { |
783 |
$('#confirm_key_accept .approve').on('click', function() { |
783 |
$('#confirm_key_accept .deny').click(); |
784 |
$('#confirm_key_accept .deny').click(); |
784 |
|
785 |
|
785 |
if ( $('#add').length > 0 ) { |
786 |
if ( $('#add').length > 0 ) { |
786 |
$('#add').submit(); |
787 |
$('#add').submit(); |
787 |
} |
788 |
} |
|
|
789 |
|
790 |
if ( $('#edit_save').length > 0 ) { |
791 |
$('#edit_save').submit(); |
792 |
} |
793 |
}); |
788 |
|
794 |
|
789 |
if ( $('#edit_save').length > 0 ) { |
|
|
790 |
$('#edit_save').submit(); |
791 |
} |
792 |
}); |
795 |
}); |
793 |
|
796 |
|
794 |
}); |
797 |
function transportChange() { |
795 |
|
798 |
let sftp_transport = $("#sftp_transport"); |
796 |
function transportChange() { |
799 |
|
797 |
let sftp_transport = $("#sftp_transport"); |
800 |
if(sftp_transport.val() == "ftp") { |
798 |
|
801 |
$("#sftp_host").removeAttr("disabled"); |
799 |
if(sftp_transport.val() == "ftp") { |
802 |
$("#sftp_port").removeAttr("disabled"); |
800 |
$("#sftp_host").removeAttr("disabled"); |
803 |
$("#sftp_passive").removeAttr("disabled"); |
801 |
$("#sftp_port").removeAttr("disabled"); |
804 |
$("#sftp_auth_mode").removeAttr("disabled"); |
802 |
$("#sftp_passive").removeAttr("disabled"); |
805 |
$("#sftp_user_name").removeAttr("disabled"); |
803 |
$("#sftp_auth_mode").removeAttr("disabled"); |
806 |
$("#sftp_password").removeAttr("disabled"); |
804 |
$("#sftp_user_name").removeAttr("disabled"); |
807 |
$("#sftp_key_file").attr("disabled", "disabled"); |
805 |
$("#sftp_password").removeAttr("disabled"); |
808 |
|
806 |
$("#sftp_key_file").attr("disabled", "disabled"); |
809 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
807 |
|
810 |
$("#sftp_auth_mode option[value='key_file']").attr("disabled", "disabled"); |
808 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
811 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
809 |
$("#sftp_auth_mode option[value='key_file']").attr("disabled", "disabled"); |
812 |
if($("#sftp_auth_mode option:selected").val() == "key_file") { |
810 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
813 |
$("#sftp_auth_mode option[value='password']").prop("selected", true); |
811 |
if($("#sftp_auth_mode option:selected").val() == "key_file") { |
814 |
} |
812 |
$("#sftp_auth_mode option[value='password']").prop("selected", true); |
815 |
|
|
|
816 |
let sftp_port = $("#sftp_port").val(); |
817 |
if(sftp_port == 22) $("#sftp_port").val("21"); |
818 |
|
819 |
authModeChange(); |
820 |
} else if(sftp_transport.val() == "sftp") { |
821 |
$("#sftp_host").removeAttr("disabled"); |
822 |
$("#sftp_port").removeAttr("disabled"); |
823 |
$("#sftp_passive").attr("disabled", "disabled"); |
824 |
$("#sftp_auth_mode").removeAttr("disabled"); |
825 |
$("#sftp_user_name").removeAttr("disabled"); |
826 |
$("#sftp_password").removeAttr("disabled"); |
827 |
$("#sftp_key_file").removeAttr("disabled"); |
828 |
|
829 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
830 |
$("#sftp_auth_mode option[value='key_file']").removeAttr("disabled"); |
831 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
832 |
$("#sftp_passive option[value='1']").prop("selected", true); |
833 |
|
834 |
let sftp_port = $("#sftp_port").val(); |
835 |
if(sftp_port == 21) $("#sftp_port").val("22"); |
836 |
|
837 |
return authModeChange(); |
813 |
} |
838 |
} |
|
|
839 |
} |
814 |
|
840 |
|
815 |
let sftp_port = $("#sftp_port").val(); |
841 |
function authModeChange() { |
816 |
if(sftp_port == 22) $("#sftp_port").val("21"); |
842 |
let sftp_auth_mode = $("#sftp_auth_mode").val(); |
817 |
|
843 |
|
818 |
authModeChange(); |
844 |
if(sftp_auth_mode == "password") { |
819 |
} else if(sftp_transport.val() == "sftp") { |
845 |
$("#sftp_password").removeAttr("disabled"); |
820 |
$("#sftp_host").removeAttr("disabled"); |
846 |
$("#sftp_key_file").attr("disabled", "disabled"); |
821 |
$("#sftp_port").removeAttr("disabled"); |
847 |
} else if(sftp_auth_mode == "key_file") { |
822 |
$("#sftp_passive").attr("disabled", "disabled"); |
848 |
$("#sftp_password").attr("disabled", "disabled"); |
823 |
$("#sftp_auth_mode").removeAttr("disabled"); |
849 |
$("#sftp_key_file").removeAttr("disabled"); |
824 |
$("#sftp_user_name").removeAttr("disabled"); |
850 |
} else { |
825 |
$("#sftp_password").removeAttr("disabled"); |
851 |
$("#sftp_password").attr("disabled", "disabled"); |
826 |
$("#sftp_key_file").removeAttr("disabled"); |
852 |
$("#sftp_key_file").attr("disabled", "disabled"); |
827 |
|
853 |
} |
828 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
|
|
829 |
$("#sftp_auth_mode option[value='key_file']").removeAttr("disabled"); |
830 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
831 |
$("#sftp_passive option[value='1']").prop("selected", true); |
832 |
|
833 |
let sftp_port = $("#sftp_port").val(); |
834 |
if(sftp_port == 21) $("#sftp_port").val("22"); |
835 |
|
836 |
return authModeChange(); |
837 |
} |
854 |
} |
838 |
} |
855 |
|
839 |
|
856 |
function modalChange() { |
840 |
function authModeChange() { |
857 |
$('#modal_message').hide(); |
841 |
let sftp_auth_mode = $("#sftp_auth_mode").val(); |
858 |
if ( $('#sftp_transport').val() == 'sftp' ) $('#modal_message').show(); |
842 |
|
859 |
|
843 |
if(sftp_auth_mode == "password") { |
860 |
$('#modal_host').text( $('#sftp_host').val() ); |
844 |
$("#sftp_password").removeAttr("disabled"); |
861 |
$('#modal_port').text( $('#sftp_port').val() ); |
845 |
$("#sftp_key_file").attr("disabled", "disabled"); |
862 |
$('#modal_transport').text( $('#sftp_transport option:selected').text() ); |
846 |
} else if(sftp_auth_mode == "key_file") { |
863 |
$('#modal_user_name').text( $('#sftp_user_name').val() ); |
847 |
$("#sftp_password").attr("disabled", "disabled"); |
864 |
$('#modal_auth_mode').text( $('#sftp_auth_mode option:selected').text() ); |
848 |
$("#sftp_key_file").removeAttr("disabled"); |
|
|
849 |
} else { |
850 |
$("#sftp_password").attr("disabled", "disabled"); |
851 |
$("#sftp_key_file").attr("disabled", "disabled"); |
852 |
} |
865 |
} |
853 |
} |
866 |
</script> |
854 |
|
867 |
[% IF op == 'test_form' %] |
855 |
function modalChange() { |
868 |
<script> |
856 |
$('#modal_message').hide(); |
869 |
$(document).ready(function() { |
857 |
if ( $('#sftp_transport').val() == 'sftp' ) $('#modal_message').show(); |
870 |
handleTests(); |
858 |
|
871 |
}); |
859 |
$('#modal_host').text( $('#sftp_host').val() ); |
|
|
860 |
$('#modal_port').text( $('#sftp_port').val() ); |
861 |
$('#modal_transport').text( $('#sftp_transport option:selected').text() ); |
862 |
$('#modal_user_name').text( $('#sftp_user_name').val() ); |
863 |
$('#modal_auth_mode').text( $('#sftp_auth_mode option:selected').text() ); |
864 |
} |
865 |
</script> |
866 |
|
867 |
[% IF op == 'test_form' %] |
868 |
<script> |
869 |
$(document).ready(function() { |
870 |
handleTests(); |
871 |
}); |
872 |
|
873 |
function handleTests() { |
874 |
var testOutput = $('#testOutput'); |
875 |
var runTests = $('#runTests'); |
876 |
|
877 |
runTests.addClass('disabled'); |
878 |
testOutput.html('<div class="spinner-border text-warning" style="height:1.5rem;width:1.5rem" role="status"><span class="sr-only">Loading...</span></div><span class="pending-loading">' + _("Running tests . . . ") + '</span>'); |
879 |
|
880 |
return $.ajax({ |
881 |
url: "/api/v1/sftp_server/[% sftp_server.id | html %]/test_connection", |
882 |
}) |
883 |
.done(function(data) { |
884 |
testOutput.text(''); |
885 |
|
886 |
for ( let [key, value] of Object.entries( data ) ) { |
887 |
var title; |
888 |
switch(key) { |
889 |
case '1_sftp_conn': |
890 |
title = _("Testing SFTP connectivity"); |
891 |
break; |
892 |
case '1_ftp_conn': |
893 |
title = _("Testing FTP connectivity"); |
894 |
break; |
895 |
case '2_ftp_login': |
896 |
title = _("Testing we can log in"); |
897 |
break; |
898 |
case '2a_sftp_cwd_dl': |
899 |
case '3a_ftp_cwd_dl': |
900 |
title = _("Testing we can cwd to download directory"); |
901 |
break; |
902 |
case '2b_sftp_ls_dl': |
903 |
case '3b_ftp_ls_dl': |
904 |
title = _("Testing we can list download directory"); |
905 |
break; |
906 |
case '2c_sftp_cwd_ul': |
907 |
case '3c_ftp_cwd_ul': |
908 |
title = _("Testing we can cwd to upload directory"); |
909 |
break; |
910 |
case '2d_sftp_ls_ul': |
911 |
case '3d_ftp_ls_ul': |
912 |
title = _("Testing we can list upload directory"); |
913 |
break; |
914 |
case '3_sftp_write': |
915 |
case '4_ftp_write': |
916 |
title = _("Testing we can write a test file"); |
917 |
break; |
918 |
case '4_sftp_del': |
919 |
case '5_ftp_del': |
920 |
title = _("Testing we can delete test file"); |
921 |
break; |
922 |
default: |
923 |
title = key |
924 |
} |
925 |
|
872 |
|
926 |
if ( value.passed ) { |
873 |
function handleTests() { |
927 |
testOutput.append( |
874 |
var testOutput = $('#testOutput'); |
928 |
'<i class="text-success fa-solid fa-circle-check"></i> ' |
875 |
var runTests = $('#runTests'); |
929 |
+ title |
876 |
|
930 |
+ '... <span class="text-success">' |
877 |
runTests.addClass('disabled'); |
931 |
+ _("Passed") |
878 |
testOutput.html('<div class="spinner-border text-warning" style="height:1.5rem;width:1.5rem" role="status"><span class="sr-only">Loading...</span></div><span class="pending-loading">' + _("Running tests . . . ") + '</span>'); |
932 |
+ '</span><br />' |
879 |
|
933 |
); |
880 |
return $.ajax({ |
934 |
if( value.msg ) testOutput.append( _("Message: ") + '<code>' + value.msg + '</code><br />' ); |
881 |
url: "/api/v1/sftp_server/[% sftp_server.id | html %]/test_connection", |
935 |
} else { |
882 |
}) |
936 |
testOutput.append( |
883 |
.done(function(data) { |
937 |
'<i class="text-danger fa-solid fa-circle-xmark"></i> ' |
884 |
testOutput.text(''); |
938 |
+ title |
885 |
|
939 |
+ '... <span class="text-danger">' |
886 |
for ( let [key, value] of Object.entries( data ) ) { |
940 |
+ _("Failed") |
887 |
var title; |
941 |
+ '</span><br />' |
888 |
switch(key) { |
942 |
); |
889 |
case '1_sftp_conn': |
943 |
if( value.err ) testOutput.append( _("Error message: ") + '<code>' + value.err + '</code><br />' ); |
890 |
title = _("Testing SFTP connectivity"); |
944 |
} |
891 |
break; |
945 |
testOutput.append( '<br />' ); |
892 |
case '1_ftp_conn': |
946 |
} |
893 |
title = _("Testing FTP connectivity"); |
947 |
}) |
894 |
break; |
948 |
.fail(function(data) { |
895 |
case '2_ftp_login': |
949 |
if( data.status == 404 ) { |
896 |
title = _("Testing we can log in"); |
950 |
return testOutput.text( '<i class="text-success fa-solid fa-circle-check"></i> ' + _("FTP/SFTP Server not found") ); |
897 |
break; |
951 |
} else { |
898 |
case '2a_sftp_cwd_dl': |
952 |
return testOutput.text( '<i class="text-success fa-solid fa-circle-check"></i> ' + _("Internal Server Error. Please check the server logs") ); |
899 |
case '3a_ftp_cwd_dl': |
|
|
900 |
title = _("Testing we can cwd to download directory"); |
901 |
break; |
902 |
case '2b_sftp_ls_dl': |
903 |
case '3b_ftp_ls_dl': |
904 |
title = _("Testing we can list download directory"); |
905 |
break; |
906 |
case '2c_sftp_cwd_ul': |
907 |
case '3c_ftp_cwd_ul': |
908 |
title = _("Testing we can cwd to upload directory"); |
909 |
break; |
910 |
case '2d_sftp_ls_ul': |
911 |
case '3d_ftp_ls_ul': |
912 |
title = _("Testing we can list upload directory"); |
913 |
break; |
914 |
case '3_sftp_write': |
915 |
case '4_ftp_write': |
916 |
title = _("Testing we can write a test file"); |
917 |
break; |
918 |
case '4_sftp_del': |
919 |
case '5_ftp_del': |
920 |
title = _("Testing we can delete test file"); |
921 |
break; |
922 |
default: |
923 |
title = key |
924 |
} |
925 |
|
926 |
if ( value.passed ) { |
927 |
testOutput.append( |
928 |
'<i class="text-success fa-solid fa-circle-check"></i> ' |
929 |
+ title |
930 |
+ '... <span class="text-success">' |
931 |
+ _("Passed") |
932 |
+ '</span><br />' |
933 |
); |
934 |
if( value.msg ) testOutput.append( _("Message: ") + '<code>' + value.msg + '</code><br />' ); |
935 |
} else { |
936 |
testOutput.append( |
937 |
'<i class="text-danger fa-solid fa-circle-xmark"></i> ' |
938 |
+ title |
939 |
+ '... <span class="text-danger">' |
940 |
+ _("Failed") |
941 |
+ '</span><br />' |
942 |
); |
943 |
if( value.err ) testOutput.append( _("Error message: ") + '<code>' + value.err + '</code><br />' ); |
944 |
} |
945 |
testOutput.append( '<br />' ); |
946 |
} |
947 |
}) |
948 |
.fail(function(data) { |
949 |
if( data.status == 404 ) { |
950 |
return testOutput.text( '<i class="text-success fa-solid fa-circle-check"></i> ' + _("FTP/SFTP Server not found") ); |
951 |
} else { |
952 |
return testOutput.text( '<i class="text-success fa-solid fa-circle-check"></i> ' + _("Internal Server Error. Please check the server logs") ); |
953 |
} |
954 |
}) |
955 |
.always(function(data) { |
956 |
runTests.removeClass('disabled'); |
957 |
}); |
953 |
} |
958 |
} |
954 |
}) |
959 |
</script> |
955 |
.always(function(data) { |
960 |
[% END %] |
956 |
runTests.removeClass('disabled'); |
|
|
957 |
}); |
958 |
} |
959 |
</script> |
960 |
[% END %] |
961 |
[% END %] |
961 |
[% END %] |
|
|
962 |
|
962 |
|
963 |
[% INCLUDE 'intranet-bottom.inc' %] |
963 |
[% INCLUDE 'intranet-bottom.inc' %] |
|
|
964 |
</div> |
964 |
- |
|
|