Line 0
Link Here
|
|
|
1 |
[% USE raw %] |
2 |
[% USE Asset %] |
3 |
[% PROCESS 'i18n.inc' %] |
4 |
[% SET footerjs = 1 %] |
5 |
[% INCLUDE 'doc-head-open.inc' %] |
6 |
<title>[% FILTER collapse %] |
7 |
[% IF op == 'add_form' %] |
8 |
[% t("New FTP/SFTP server") | html %] › |
9 |
[% ELSIF op == 'edit_form' %] |
10 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] › |
11 |
[% ELSIF op == 'test_form' %] |
12 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] › |
13 |
[% END %] |
14 |
[% t("FTP/SFTP Servers") | html %] › |
15 |
[% t("Administration") | html %] › |
16 |
[% t("Koha") | html %] |
17 |
[% END %]</title> |
18 |
[% INCLUDE 'doc-head-close.inc' %] |
19 |
<style> |
20 |
#testOutput { |
21 |
font-size: 1.25rem; |
22 |
} |
23 |
|
24 |
#testOutput .pending-loading { |
25 |
font-size: 1.5rem; |
26 |
margin-left: 1.25rem; |
27 |
} |
28 |
|
29 |
#testOutput code { |
30 |
font-size: 87.5%; |
31 |
color: #e83e8c; |
32 |
background: transparent; |
33 |
word-break: break-word; |
34 |
} |
35 |
</style> |
36 |
|
37 |
</head> |
38 |
|
39 |
<body id="admin_sftp_servers" class="admin"> |
40 |
[% WRAPPER 'header.inc' %] |
41 |
[% INCLUDE 'prefs-admin-search.inc' %] |
42 |
[% END %] |
43 |
|
44 |
[% WRAPPER 'sub-header.inc' %] |
45 |
[% WRAPPER breadcrumbs %] |
46 |
[% WRAPPER breadcrumb_item %] |
47 |
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> |
48 |
[% END %] |
49 |
|
50 |
[% IF op == 'add_form' || op == 'edit_form' || op == 'test_form' %] |
51 |
[% WRAPPER breadcrumb_item %] |
52 |
<a href="/cgi-bin/koha/admin/sftp_servers.pl">FTP/SFTP servers</a> |
53 |
[% END %] |
54 |
[% END %] |
55 |
|
56 |
[% IF op == 'add_form' %] |
57 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
58 |
<span>New FTP/SFTP server</span> |
59 |
[% END %] |
60 |
|
61 |
[% ELSIF op == 'edit_form' %] |
62 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
63 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
64 |
[% END %] |
65 |
|
66 |
[% ELSIF op == 'test_form' %] |
67 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
68 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
69 |
[% END %] |
70 |
|
71 |
[% ELSE %] |
72 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
73 |
<span>FTP/SFTP servers</span> |
74 |
[% END %] |
75 |
[% END %] |
76 |
[% END #/ WRAPPER breadcrumbs %] |
77 |
[% END #/ WRAPPER sub-header.inc %] |
78 |
|
79 |
<div class="main container-fluid"> |
80 |
<div class="row"> |
81 |
<div class="col-md-10 order-md-2 order-sm-1"> |
82 |
<main> |
83 |
[% INCLUDE 'messages.inc' %] |
84 |
|
85 |
[% FOREACH m IN messages %] |
86 |
<div class="alert alert-[% m.type | html %]" id="sftp_action_result_dialog"> |
87 |
[% SWITCH m.code %] |
88 |
[% CASE 'error_on_insert' %] |
89 |
<span>An error occurred when adding the server. The passed ID already exists.</span> |
90 |
[% CASE 'error_on_update' %] |
91 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
92 |
[% CASE 'error_on_edit' %] |
93 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
94 |
[% CASE 'error_on_test' %] |
95 |
<span>An error occurred when connecting to this server. Please see the text below for more information.</span> |
96 |
[% CASE 'success_on_update' %] |
97 |
<span>Server updated successfully.</span> |
98 |
[% CASE 'success_on_insert' %] |
99 |
<span>Server added successfully.</span> |
100 |
[% CASE %] |
101 |
<span>[% m.code | html %]</span> |
102 |
[% 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> |
118 |
<div class="modal-body"> |
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> |
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> |
121 |
<table class="mx-4 mb-3"> |
122 |
<thead></thead> |
123 |
<tbody> |
124 |
<tr> |
125 |
<td><strong>Host</strong></td> |
126 |
<td id="modal_host"></td> |
127 |
</tr> |
128 |
<tr> |
129 |
<td><strong>Port</strong></td> |
130 |
<td id="modal_port"></td> |
131 |
</tr> |
132 |
<tr> |
133 |
<td><strong>Transport</strong></td> |
134 |
<td id="modal_transport"></td> |
135 |
</tr> |
136 |
<tr> |
137 |
<td><strong>Username</strong></td> |
138 |
<td id="modal_user_name"></td> |
139 |
</tr> |
140 |
<tr> |
141 |
<td><strong>Authentication mode</strong></td> |
142 |
<td id="modal_auth_mode"></td> |
143 |
</tr> |
144 |
</tbody> |
145 |
</table> |
146 |
<p>If you are ready to progress with these details, please click Save.</p> |
147 |
</div> |
148 |
<div class="modal-footer"> |
149 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
150 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
151 |
</div> |
152 |
</form> |
153 |
</div> |
154 |
</div> |
155 |
</div> |
156 |
<!-- END Modal --> |
157 |
|
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_passiv">Passive mode: </label> |
195 |
<select name="sftp_passiv" id="sftp_passiv" 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 |
</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_passiv">Passive mode: </label> |
346 |
<select name="sftp_passiv" id="sftp_passiv" disabled="disabled"> |
347 |
[% IF sftp_server.passiv == 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.passiv == 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 |
|
430 |
[% IF op == 'test_form' %] |
431 |
|
432 |
<h1>[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
433 |
[% IF sftp_server.id %] |
434 |
<div class="page-section"> |
435 |
[% IF sftp_server.transport == 'sftp' %] |
436 |
<div class="alert alert-warning"> |
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. |
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> |
554 |
<div class="modal-body"> |
555 |
<div id="delete_confirm_dialog"></div> |
556 |
</div> |
557 |
<div class="modal-footer"> |
558 |
<button type="button" class="btn btn-danger" id="delete_confirm_modal_button" data-bs-toggle="modal">Delete</button> |
559 |
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button> |
560 |
</div> |
561 |
</div> <!-- /.modal-content --> |
562 |
</div> <!-- /.modal-dialog --> |
563 |
</div> <!-- #delete_confirm_modal --> |
564 |
|
565 |
</main> |
566 |
</div> <!-- /.col-md-10.order-md-2 --> |
567 |
|
568 |
<div class="col-md-2 order-sm-2 order-md-1"> |
569 |
<aside> |
570 |
[% INCLUDE 'admin-menu.inc' %] |
571 |
</aside> |
572 |
</div> <!-- /.col-md-2.order-md-1 --> |
573 |
</div> <!-- /.row --> |
574 |
|
575 |
|
576 |
[% MACRO jsinclude BLOCK %] |
577 |
[% Asset.js("js/admin-menu.js") | $raw %] |
578 |
[% INCLUDE 'datatables.inc' %] |
579 |
<script> |
580 |
$(document).ready(function() { |
581 |
|
582 |
var sftp_servers_url = '/api/v1/config/sftp_servers'; |
583 |
window.sftp_servers = $("#sftp_servers").kohaTable({ |
584 |
"ajax": { |
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 |
}, |
619 |
{ |
620 |
"data": "transport", |
621 |
"render": function(data, type, row, meta) { |
622 |
return data.toUpperCase(); |
623 |
}, |
624 |
"searchable": true, |
625 |
"orderable": false |
626 |
}, |
627 |
{ |
628 |
"data": "auth_mode", |
629 |
"render": function(data, type, row, meta) { |
630 |
if(data == "password") { |
631 |
return _("Password-based"); |
632 |
} else if(data == "key_file") { |
633 |
return _("Key file-based"); |
634 |
} else { |
635 |
return _("No authentication"); |
636 |
} |
637 |
}, |
638 |
"searchable": false, |
639 |
"orderable": false |
640 |
}, |
641 |
{ |
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 |
}, |
655 |
"searchable": false, |
656 |
"orderable": false |
657 |
}, |
658 |
{ |
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 |
}, |
667 |
"searchable": false, |
668 |
"orderable": false |
669 |
}, |
670 |
{ |
671 |
"data": "status", |
672 |
"render": function(data, type, row, meta) { |
673 |
if (data == "tests_ok") { |
674 |
return _("Tests passing"); |
675 |
} else if (data == "tests_failed") { |
676 |
return _("Tests failing"); |
677 |
} else { |
678 |
return "<em>" + _("Never used") + "</em>"; |
679 |
} |
680 |
}, |
681 |
"searchable": false, |
682 |
"orderable": false |
683 |
}, |
684 |
{ |
685 |
"data": "debug", |
686 |
"render": function(data, type, row, meta) { |
687 |
if(data == true) { |
688 |
return "[% tp("Active", "On") | html %]"; |
689 |
} |
690 |
else { |
691 |
return _("Off"); |
692 |
} |
693 |
}, |
694 |
"searchable": false, |
695 |
"orderable": false |
696 |
}, |
697 |
{ |
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 |
}, |
704 |
"searchable": false, |
705 |
"orderable": false |
706 |
} |
707 |
], |
708 |
createdRow: function(row, data, dataIndex) { |
709 |
if(data.is_default) { |
710 |
$(row).addClass('default warn'); |
711 |
} |
712 |
if(data.debug) { |
713 |
$(row).addClass('debug'); |
714 |
} |
715 |
}, |
716 |
}); |
717 |
|
718 |
$('#sftp_servers').on("click", '.delete_server', function() { |
719 |
var sftp_server_id = $(this).data('sftp-server-id'); |
720 |
var sftp_server_name = decodeURIComponent($(this).data('sftp-server-name')); |
721 |
|
722 |
$("#delete_confirm_dialog").html( |
723 |
_("You are about to delete the '%s' FTP/SFTP server.").format(sftp_server_name) |
724 |
); |
725 |
$("#delete_confirm_modal_button").data('sftp-server-id', sftp_server_id); |
726 |
$("#delete_confirm_modal_button").data('sftp-server-name', sftp_server_name); |
727 |
}); |
728 |
|
729 |
$("#delete_confirm_modal_button").on("click", function() { |
730 |
|
731 |
var sftp_server_id = $(this).data('sftp-server-id'); |
732 |
var sftp_server_name = $(this).data('sftp-server-name'); |
733 |
|
734 |
$.ajax({ |
735 |
method: "DELETE", |
736 |
url: "/api/v1/config/sftp_servers/"+sftp_server_id |
737 |
}).success(function() { |
738 |
window.sftp_servers.api().ajax.reload(function(data) { |
739 |
$("#sftp_action_result_dialog").hide(); |
740 |
$("#sftp_delete_success").html(_("Server '%s' deleted successfully.").format(sftp_server_name)).show(); |
741 |
}); |
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 |
}); |
747 |
}); |
748 |
|
749 |
transportChange(); |
750 |
$("#sftp_transport").on("change", function(event) { |
751 |
transportChange(); |
752 |
}); |
753 |
|
754 |
authModeChange(); |
755 |
$("#sftp_auth_mode").on("change", function(event) { |
756 |
authModeChange(); |
757 |
}); |
758 |
|
759 |
$('#confirm_key_accept_submit').on('click', function(event) { |
760 |
event.preventDefault(); |
761 |
|
762 |
if ( $('#add').length > 0 ) { |
763 |
if( $('#add').valid() == true ) { |
764 |
modalChange(); |
765 |
$('#confirm_key_accept').modal('show'); |
766 |
} else { |
767 |
$('#confirm_key_accept').modal('hide'); |
768 |
} |
769 |
} |
770 |
|
771 |
if ( $('#edit_save').length > 0 ) { |
772 |
if( $('#edit_save').valid() == true ) { |
773 |
modalChange(); |
774 |
$('#confirm_key_accept').modal('show'); |
775 |
} else { |
776 |
$('#confirm_key_accept').modal('hide'); |
777 |
} |
778 |
} |
779 |
|
780 |
}); |
781 |
|
782 |
$('#confirm_key_accept .approve').on('click', function() { |
783 |
$('#confirm_key_accept .deny').click(); |
784 |
|
785 |
if ( $('#add').length > 0 ) { |
786 |
$('#add').submit(); |
787 |
} |
788 |
|
789 |
if ( $('#edit_save').length > 0 ) { |
790 |
$('#edit_save').submit(); |
791 |
} |
792 |
}); |
793 |
|
794 |
}); |
795 |
|
796 |
function transportChange() { |
797 |
let sftp_transport = $("#sftp_transport"); |
798 |
|
799 |
if(sftp_transport.val() == "ftp") { |
800 |
$("#sftp_host").removeAttr("disabled"); |
801 |
$("#sftp_port").removeAttr("disabled"); |
802 |
$("#sftp_passiv").removeAttr("disabled"); |
803 |
$("#sftp_auth_mode").removeAttr("disabled"); |
804 |
$("#sftp_user_name").removeAttr("disabled"); |
805 |
$("#sftp_password").removeAttr("disabled"); |
806 |
$("#sftp_key_file").attr("disabled", "disabled"); |
807 |
|
808 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
809 |
$("#sftp_auth_mode option[value='key_file']").attr("disabled", "disabled"); |
810 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
811 |
if($("#sftp_auth_mode option:selected").val() == "key_file") { |
812 |
$("#sftp_auth_mode option[value='password']").prop("selected", true); |
813 |
} |
814 |
|
815 |
let sftp_port = $("#sftp_port").val(); |
816 |
if(sftp_port == 22) $("#sftp_port").val("21"); |
817 |
|
818 |
authModeChange(); |
819 |
} else if(sftp_transport.val() == "sftp") { |
820 |
$("#sftp_host").removeAttr("disabled"); |
821 |
$("#sftp_port").removeAttr("disabled"); |
822 |
$("#sftp_passiv").attr("disabled", "disabled"); |
823 |
$("#sftp_auth_mode").removeAttr("disabled"); |
824 |
$("#sftp_user_name").removeAttr("disabled"); |
825 |
$("#sftp_password").removeAttr("disabled"); |
826 |
$("#sftp_key_file").removeAttr("disabled"); |
827 |
|
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_passiv 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 |
} |
838 |
} |
839 |
|
840 |
function authModeChange() { |
841 |
let sftp_auth_mode = $("#sftp_auth_mode").val(); |
842 |
|
843 |
if(sftp_auth_mode == "password") { |
844 |
$("#sftp_password").removeAttr("disabled"); |
845 |
$("#sftp_key_file").attr("disabled", "disabled"); |
846 |
} else if(sftp_auth_mode == "key_file") { |
847 |
$("#sftp_password").attr("disabled", "disabled"); |
848 |
$("#sftp_key_file").removeAttr("disabled"); |
849 |
} else { |
850 |
$("#sftp_password").attr("disabled", "disabled"); |
851 |
$("#sftp_key_file").attr("disabled", "disabled"); |
852 |
} |
853 |
} |
854 |
|
855 |
function modalChange() { |
856 |
$('#modal_message').hide(); |
857 |
if ( $('#sftp_transport').val() == 'sftp' ) $('#modal_message').show(); |
858 |
|
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 |
|
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 |
}); |
958 |
} |
959 |
</script> |
960 |
[% END %] |
961 |
[% END %] |
962 |
|
963 |
[% INCLUDE 'intranet-bottom.inc' %] |