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_debug_mode">Debug mode: </label> |
225 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
226 |
<option value="1">Enabled</option> |
227 |
<option value="0" selected="selected">Disabled</option> |
228 |
</select> |
229 |
<span class="hint">Enables additional debug output in the logs</span> |
230 |
</li> |
231 |
</ol> |
232 |
</fieldset> |
233 |
<fieldset class="action"> |
234 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
235 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
236 |
</fieldset> |
237 |
</form> |
238 |
[% END %] |
239 |
|
240 |
[% IF op == 'edit_form' && !messages %] |
241 |
<!-- Modal --> |
242 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
243 |
<div class="modal-dialog modal-lg"> |
244 |
<div class="modal-content modal-lg"> |
245 |
<div class="modal-header"> |
246 |
<h1 class="modal-title">Are you sure?</h1> |
247 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
248 |
</div> |
249 |
<div class="modal-body"> |
250 |
<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> |
251 |
<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> |
252 |
<table class="mx-4 mb-3"> |
253 |
<thead></thead> |
254 |
<tbody> |
255 |
<tr> |
256 |
<td><strong>Host</strong></td> |
257 |
<td id="modal_host"></td> |
258 |
</tr> |
259 |
<tr> |
260 |
<td><strong>Port</strong></td> |
261 |
<td id="modal_port"></td> |
262 |
</tr> |
263 |
<tr> |
264 |
<td><strong>Transport</strong></td> |
265 |
<td id="modal_transport"></td> |
266 |
</tr> |
267 |
<tr> |
268 |
<td><strong>Username</strong></td> |
269 |
<td id="modal_user_name"></td> |
270 |
</tr> |
271 |
<tr> |
272 |
<td><strong>Authentication mode</strong></td> |
273 |
<td id="modal_auth_mode"></td> |
274 |
</tr> |
275 |
</tbody> |
276 |
</table> |
277 |
<p>If you are ready to progress with these details, please click Save.</p> |
278 |
</div> |
279 |
<div class="modal-footer"> |
280 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
281 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
282 |
</div> |
283 |
</form> |
284 |
</div> |
285 |
</div> |
286 |
</div> |
287 |
<!-- END Modal --> |
288 |
|
289 |
<h1>[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
290 |
|
291 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
292 |
[% INCLUDE 'csrf-token.inc' %] |
293 |
<input type="hidden" name="op" value="cud-edit_save" /> |
294 |
<input type="hidden" name="sftp_server_id" value="[%- sftp_server.id | html -%]" /> |
295 |
<fieldset class="rows"> |
296 |
<ol> |
297 |
<li> |
298 |
<label for="sftp_name" class="required">Name: </label> |
299 |
<input type="text" value="[% sftp_server.name | html %]" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
300 |
<span class="required">Required</span> |
301 |
</li> |
302 |
</ol> |
303 |
</fieldset> |
304 |
|
305 |
<fieldset class="rows"> |
306 |
<ol> |
307 |
<li> |
308 |
<label for="sftp_host" class="required">Host: </label> |
309 |
<input type="text" value="[% sftp_server.host | html %]" name="sftp_host" id="sftp_host" size="60" class="required" /> |
310 |
<span class="required">Required</span> |
311 |
</li> |
312 |
<li> |
313 |
<label for="sftp_port" class="required">Port: </label> |
314 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="[% sftp_server.port | html %]" name="sftp_port" id="sftp_port" size="20" class="required"/> |
315 |
<span class="required">Required</span> |
316 |
</li> |
317 |
<li> |
318 |
<label for="sftp_transport" class="required">Transport: </label> |
319 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
320 |
[% IF sftp_server.transport == 'ftp' %] |
321 |
<option value="ftp" selected="selected">FTP</option> |
322 |
[% ELSE %] |
323 |
<option value="ftp">FTP</option> |
324 |
[% END %] |
325 |
[% IF sftp_server.transport == 'sftp' %] |
326 |
<option value="sftp" selected="selected">SFTP</option> |
327 |
[% ELSE %] |
328 |
<option value="sftp">SFTP</option> |
329 |
[% END %] |
330 |
</select> |
331 |
<span class="required">Required</span> |
332 |
</li> |
333 |
<li> |
334 |
<label for="sftp_passiv">Passive mode: </label> |
335 |
<select name="sftp_passiv" id="sftp_passiv" disabled="disabled"> |
336 |
[% IF sftp_server.passiv == 1 %] |
337 |
<option value="1" selected="selected">Enabled (Recommended)</option> |
338 |
[% ELSE %] |
339 |
<option value="1">Enabled (Recommended)</option> |
340 |
[% END %] |
341 |
[% IF sftp_server.passiv == 0 %] |
342 |
<option value="0" selected="selected">Disabled</option> |
343 |
[% ELSE %] |
344 |
<option value="0">Disabled</option> |
345 |
[% END %] |
346 |
</select> |
347 |
<span class="hint">Only applies to FTP connections</span> |
348 |
</li> |
349 |
<li> |
350 |
<label for="sftp_auth_mode">Authentication mode: </label> |
351 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
352 |
[% IF sftp_server.auth_mode == 'password' %] |
353 |
<option value="password" selected="selected">Password-based</option> |
354 |
[% ELSE %] |
355 |
option value="password">Password-based</option> |
356 |
[% END %] |
357 |
[% IF sftp_server.auth_mode == 'key_file' %] |
358 |
<option value="key_file" selected="selected">Key file-based</option> |
359 |
[% ELSE %] |
360 |
<option value="key_file">Key file-based</option> |
361 |
[% END %] |
362 |
[% IF sftp_server.auth_mode == 'noauth' %] |
363 |
<option value="noauth" selected="selected">No authentication</option> |
364 |
[% ELSE %] |
365 |
<option value="noauth">No authentication</option> |
366 |
[% END %] |
367 |
</select> |
368 |
</li> |
369 |
<li> |
370 |
<label for="sftp_user_name" class="required">Username: </label> |
371 |
<input type="text" value="[% sftp_server.user_name | html %]" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
372 |
<span class="required">Required</span> |
373 |
</li> |
374 |
<li> |
375 |
<label for="sftp_password">Password: </label> |
376 |
<input type="password" value="[% sftp_server_plain_text_password | html %]" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
377 |
</li> |
378 |
<li> |
379 |
<label for="sftp_key_file">Key file path: </label> |
380 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58">[% sftp_server_plain_text_key | html %]</textarea> |
381 |
<span class="hint">Only applies to SFTP connections</span> |
382 |
</li> |
383 |
<li> |
384 |
<label for="sftp_debug_mode">Debug mode: </label> |
385 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
386 |
[% IF sftp_server.debug == 1 %] |
387 |
<option value="1" selected="selected">Enabled</option> |
388 |
[% ELSE %] |
389 |
<option value="1">Enabled</option> |
390 |
[% END %] |
391 |
[% IF sftp_server.debug == 0 %] |
392 |
<option value="0" selected="selected">Disabled</option> |
393 |
[% ELSE %] |
394 |
<option value="0">Disabled</option> |
395 |
[% END %] |
396 |
</select> |
397 |
<span class="hint">Enables additional debug output in the logs</span> |
398 |
</li> |
399 |
</ol> |
400 |
</fieldset> |
401 |
<fieldset class="action"> |
402 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
403 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
404 |
</fieldset> |
405 |
</form> |
406 |
[% END %] |
407 |
|
408 |
[% IF op == 'test_form' %] |
409 |
<div id="toolbar" class="btn-toolbar"> |
410 |
<a class="btn btn-default" id="newtest" href="/cgi-bin/koha/admin/sftp_servers.pl?op=test_form&sftp_server_id=[% sftp_server.id | html %]"><i class="fa-solid fa-rotate-right"></i> Retry test</a> |
411 |
</div> |
412 |
|
413 |
<h1>[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
414 |
<div class="page-section"> |
415 |
[% IF sftp_server.id %] |
416 |
<div class="row"> |
417 |
<div class="col-12 col-lg-6 order-1 order-lg-0"> |
418 |
<h3>Test results</h3> |
419 |
<div id="testOutput"> |
420 |
<div class="spinner-border text-warning" style="height:1.5rem;width:1.5rem" role="status"> |
421 |
<span class="sr-only">Loading...</span> |
422 |
</div> |
423 |
<span class="pending-loading">Running tests...</span> |
424 |
</div> |
425 |
</div> |
426 |
<div class="col-12 col-lg-6 order-0 order-lg-1"> |
427 |
<h3>Test details</h3> |
428 |
<p>Connection details are as follows:</p> |
429 |
<table class="mx-4 mb-3"> |
430 |
<thead></thead> |
431 |
<tbody> |
432 |
<tr> |
433 |
<td><strong>Host</strong></td> |
434 |
<td>[% sftp_server.host | html %]</td> |
435 |
</tr> |
436 |
<tr> |
437 |
<td><strong>Port</strong></td> |
438 |
<td>[% sftp_server.port | html %]</td> |
439 |
</tr> |
440 |
<tr> |
441 |
<td><strong>Transport</strong></td> |
442 |
<td>[% sftp_server.transport FILTER upper | html %]</td> |
443 |
</tr> |
444 |
<tr> |
445 |
<td><strong>Username</strong></td> |
446 |
<td>[% sftp_server.user_name | html %]</td> |
447 |
</tr> |
448 |
<tr> |
449 |
<td><strong>Authentication mode</strong></td> |
450 |
<td> |
451 |
[% IF sftp_server.auth_mode == 'password' %] |
452 |
Password-based |
453 |
[% ELSE %] |
454 |
Key file-based |
455 |
[% END %] |
456 |
</td> |
457 |
</tr> |
458 |
</tbody> |
459 |
</table> |
460 |
</div> |
461 |
</div> |
462 |
[% ELSE %] |
463 |
<h3>Oops – Not Found</h3> |
464 |
<p>An FTP/SFTP server with that ID was not found. Please go back and try again.</p> |
465 |
[% END %] |
466 |
</div> |
467 |
[% END %] |
468 |
|
469 |
[% IF op == 'list' %] |
470 |
|
471 |
<div id="toolbar" class="btn-toolbar"> |
472 |
<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> |
473 |
</div> |
474 |
|
475 |
<h1>FTP/SFTP servers</h1> |
476 |
|
477 |
[% IF servers_count < 1 %] |
478 |
<div class="alert alert-info" id="dno_servers_message"> |
479 |
<p> |
480 |
<em>There are no FTP/SFTP servers defined.</em><br /> |
481 |
To create one, use the <strong>new FTP/SFTP server</strong> button above. |
482 |
</p> |
483 |
</div> |
484 |
[% ELSE %] |
485 |
<div class="page-section"> |
486 |
<table id="sftp_servers"> |
487 |
<thead> |
488 |
<tr> |
489 |
<th>Name</th> |
490 |
<th>Host</th> |
491 |
<th>Port</th> |
492 |
<th>Transport</th> |
493 |
<th>Passive mode</th> |
494 |
<th>Authentication mode</th> |
495 |
<th>Username</th> |
496 |
<th>Debug</th> |
497 |
<th data-class-name="actions noExport">Actions</th> |
498 |
</tr> |
499 |
</thead> |
500 |
</table> |
501 |
</div> <!-- /.page-section --> |
502 |
[% END %] |
503 |
[% END %] |
504 |
|
505 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
506 |
<div class="modal-dialog"> |
507 |
<div class="modal-content"> |
508 |
<div class="modal-header"> |
509 |
<h1 class="modal-title" id="delete_confirm_modal_label">Delete server</h1> |
510 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
511 |
</div> |
512 |
<div class="modal-body"> |
513 |
<div id="delete_confirm_dialog"></div> |
514 |
</div> |
515 |
<div class="modal-footer"> |
516 |
<button type="button" class="btn btn-danger" id="delete_confirm_modal_button" data-bs-toggle="modal">Delete</button> |
517 |
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button> |
518 |
</div> |
519 |
</div> <!-- /.modal-content --> |
520 |
</div> <!-- /.modal-dialog --> |
521 |
</div> <!-- #delete_confirm_modal --> |
522 |
|
523 |
</main> |
524 |
</div> <!-- /.col-md-10.order-md-2 --> |
525 |
|
526 |
<div class="col-md-2 order-sm-2 order-md-1"> |
527 |
<aside> |
528 |
[% INCLUDE 'admin-menu.inc' %] |
529 |
</aside> |
530 |
</div> <!-- /.col-md-2.order-md-1 --> |
531 |
</div> <!-- /.row --> |
532 |
|
533 |
|
534 |
[% MACRO jsinclude BLOCK %] |
535 |
[% Asset.js("js/admin-menu.js") | $raw %] |
536 |
[% INCLUDE 'datatables.inc' %] |
537 |
<script> |
538 |
$(document).ready(function() { |
539 |
|
540 |
var sftp_servers_url = '/api/v1/config/sftp_servers'; |
541 |
window.sftp_servers = $("#sftp_servers").kohaTable({ |
542 |
"ajax": { |
543 |
"url": sftp_servers_url |
544 |
}, |
545 |
'language': { |
546 |
'emptyTable': '<div class="alert alert-info">'+_("There are no FTP/SFTP servers defined.")+'</div>' |
547 |
}, |
548 |
"columnDefs": [ { |
549 |
"targets": [0,1], |
550 |
"render": function(data, type, row, meta) { |
551 |
if(type == 'display') { |
552 |
if(data != null) { |
553 |
return data.escapeHtml(); |
554 |
} |
555 |
else { |
556 |
return "Default"; |
557 |
} |
558 |
} |
559 |
return data; |
560 |
} |
561 |
} ], |
562 |
"columns": [ |
563 |
{ |
564 |
"data": "name", |
565 |
"searchable": true, |
566 |
"orderable": true |
567 |
}, |
568 |
{ |
569 |
"data": "host", |
570 |
"searchable": true, |
571 |
"orderable": true |
572 |
}, |
573 |
{ |
574 |
"data": "port", |
575 |
"searchable": true, |
576 |
"orderable": false |
577 |
}, |
578 |
{ |
579 |
"data": "transport", |
580 |
"render": function(data, type, row, meta) { |
581 |
return data.toUpperCase(); |
582 |
}, |
583 |
"searchable": true, |
584 |
"orderable": false |
585 |
}, |
586 |
{ |
587 |
"data": "passiv", |
588 |
"render": function(data, type, row, meta) { |
589 |
if(data == true) { |
590 |
return "[% tp("Active", "On") | html %]"; |
591 |
} |
592 |
else { |
593 |
return _("Off"); |
594 |
} |
595 |
}, |
596 |
"searchable": false, |
597 |
"orderable": false |
598 |
}, |
599 |
{ |
600 |
"data": "auth_mode", |
601 |
"render": function(data, type, row, meta) { |
602 |
if(data == "password") { |
603 |
return _("Password-based"); |
604 |
} |
605 |
else if(data == "key_file") { |
606 |
return _("Key file-based"); |
607 |
} |
608 |
else { |
609 |
return _("No authentication"); |
610 |
} |
611 |
}, |
612 |
"searchable": false, |
613 |
"orderable": false |
614 |
}, |
615 |
{ |
616 |
"data": "user_name", |
617 |
"searchable": false, |
618 |
"orderable": false |
619 |
}, |
620 |
{ |
621 |
"data": "debug", |
622 |
"render": function(data, type, row, meta) { |
623 |
if(data == true) { |
624 |
return "[% tp("Active", "On") | html %]"; |
625 |
} |
626 |
else { |
627 |
return _("Off"); |
628 |
} |
629 |
}, |
630 |
"searchable": false, |
631 |
"orderable": false |
632 |
}, |
633 |
{ |
634 |
"data": function(row, type, val, meta) { |
635 |
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"; |
636 |
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"; |
637 |
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>'; |
638 |
return result; |
639 |
}, |
640 |
"searchable": false, |
641 |
"orderable": false |
642 |
} |
643 |
], |
644 |
createdRow: function(row, data, dataIndex) { |
645 |
if(data.is_default) { |
646 |
$(row).addClass('default warn'); |
647 |
} |
648 |
if(data.debug) { |
649 |
$(row).addClass('debug'); |
650 |
} |
651 |
}, |
652 |
}); |
653 |
|
654 |
$('#sftp_servers').on("click", '.delete_server', function() { |
655 |
var sftp_server_id = $(this).data('sftp-server-id'); |
656 |
var sftp_server_name = decodeURIComponent($(this).data('sftp-server-name')); |
657 |
|
658 |
$("#delete_confirm_dialog").html( |
659 |
_("You are about to delete the '%s' FTP/SFTP server.").format(sftp_server_name) |
660 |
); |
661 |
$("#delete_confirm_modal_button").data('sftp-server-id', sftp_server_id); |
662 |
$("#delete_confirm_modal_button").data('sftp-server-name', sftp_server_name); |
663 |
}); |
664 |
|
665 |
$("#delete_confirm_modal_button").on("click", function() { |
666 |
|
667 |
var sftp_server_id = $(this).data('sftp-server-id'); |
668 |
var sftp_server_name = $(this).data('sftp-server-name'); |
669 |
|
670 |
$.ajax({ |
671 |
method: "DELETE", |
672 |
url: "/api/v1/config/sftp_servers/"+sftp_server_id |
673 |
}).success(function() { |
674 |
window.sftp_servers.api().ajax.reload(function(data) { |
675 |
$("#sftp_action_result_dialog").hide(); |
676 |
$("#sftp_delete_success").html(_("Server '%s' deleted successfully.").format(sftp_server_name)).show(); |
677 |
}); |
678 |
}).fail(function() { |
679 |
$("#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(); |
680 |
}).done(function() { |
681 |
$("#delete_confirm_modal").modal('hide'); |
682 |
}); |
683 |
}); |
684 |
|
685 |
if(window.location.pathname == '/cgi-bin/koha/admin/sftp_servers.pl') { |
686 |
handleTests(); |
687 |
} |
688 |
|
689 |
transportChange(); |
690 |
$("#sftp_transport").on("change", function(event) { |
691 |
transportChange(); |
692 |
}); |
693 |
|
694 |
authModeChange(); |
695 |
$("#sftp_auth_mode").on("change", function(event) { |
696 |
authModeChange(); |
697 |
}); |
698 |
|
699 |
$('#confirm_key_accept_submit').on('click', function(event) { |
700 |
event.preventDefault(); |
701 |
|
702 |
if ( $('#add').length > 0 ) { |
703 |
if( $('#add').valid() == true ) { |
704 |
modalChange(); |
705 |
$('#confirm_key_accept').modal('show'); |
706 |
} else { |
707 |
$('#confirm_key_accept').modal('hide'); |
708 |
} |
709 |
} |
710 |
|
711 |
if ( $('#edit_save').length > 0 ) { |
712 |
if( $('#edit_save').valid() == true ) { |
713 |
modalChange(); |
714 |
$('#confirm_key_accept').modal('show'); |
715 |
} else { |
716 |
$('#confirm_key_accept').modal('hide'); |
717 |
} |
718 |
} |
719 |
|
720 |
}); |
721 |
|
722 |
$('#confirm_key_accept .approve').on('click', function() { |
723 |
$('#confirm_key_accept .deny').click(); |
724 |
|
725 |
if ( $('#add').length > 0 ) { |
726 |
$('#add').submit(); |
727 |
} |
728 |
|
729 |
if ( $('#edit_save').length > 0 ) { |
730 |
$('#edit_save').submit(); |
731 |
} |
732 |
}); |
733 |
|
734 |
}); |
735 |
|
736 |
function transportChange() { |
737 |
let sftp_transport = $("#sftp_transport"); |
738 |
|
739 |
if(sftp_transport.val() == "ftp") { |
740 |
$("#sftp_host").removeAttr("disabled"); |
741 |
$("#sftp_port").removeAttr("disabled"); |
742 |
$("#sftp_passiv").removeAttr("disabled"); |
743 |
$("#sftp_auth_mode").removeAttr("disabled"); |
744 |
$("#sftp_user_name").removeAttr("disabled"); |
745 |
$("#sftp_password").removeAttr("disabled"); |
746 |
$("#sftp_key_file").attr("disabled", "disabled"); |
747 |
|
748 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
749 |
$("#sftp_auth_mode option[value='key_file']").attr("disabled", "disabled"); |
750 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
751 |
if($("#sftp_auth_mode option:selected").val() == "key_file") { |
752 |
$("#sftp_auth_mode option[value='password']").prop("selected", true); |
753 |
} |
754 |
|
755 |
let sftp_port = $("#sftp_port").val(); |
756 |
if(sftp_port == 22) $("#sftp_port").val("21"); |
757 |
|
758 |
authModeChange(); |
759 |
} else if(sftp_transport.val() == "sftp") { |
760 |
$("#sftp_host").removeAttr("disabled"); |
761 |
$("#sftp_port").removeAttr("disabled"); |
762 |
$("#sftp_passiv").attr("disabled", "disabled"); |
763 |
$("#sftp_auth_mode").removeAttr("disabled"); |
764 |
$("#sftp_user_name").removeAttr("disabled"); |
765 |
$("#sftp_password").removeAttr("disabled"); |
766 |
$("#sftp_key_file").removeAttr("disabled"); |
767 |
|
768 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
769 |
$("#sftp_auth_mode option[value='key_file']").removeAttr("disabled"); |
770 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
771 |
$("#sftp_passiv option[value='1']").prop("selected", true); |
772 |
|
773 |
let sftp_port = $("#sftp_port").val(); |
774 |
if(sftp_port == 21) $("#sftp_port").val("22"); |
775 |
|
776 |
return authModeChange(); |
777 |
} |
778 |
} |
779 |
|
780 |
function authModeChange() { |
781 |
let sftp_auth_mode = $("#sftp_auth_mode").val(); |
782 |
|
783 |
if(sftp_auth_mode == "password") { |
784 |
$("#sftp_password").removeAttr("disabled"); |
785 |
$("#sftp_key_file").attr("disabled", "disabled"); |
786 |
} else if(sftp_auth_mode == "key_file") { |
787 |
$("#sftp_password").attr("disabled", "disabled"); |
788 |
$("#sftp_key_file").removeAttr("disabled"); |
789 |
} else { |
790 |
$("#sftp_password").attr("disabled", "disabled"); |
791 |
$("#sftp_key_file").attr("disabled", "disabled"); |
792 |
} |
793 |
} |
794 |
|
795 |
function modalChange() { |
796 |
$('#modal_message').hide(); |
797 |
if ( $('#sftp_transport').val() == 'sftp' ) $('#modal_message').show(); |
798 |
|
799 |
$('#modal_host').text( $('#sftp_host').val() ); |
800 |
$('#modal_port').text( $('#sftp_port').val() ); |
801 |
$('#modal_transport').text( $('#sftp_transport option:selected').text() ); |
802 |
$('#modal_user_name').text( $('#sftp_user_name').val() ); |
803 |
$('#modal_auth_mode').text( $('#sftp_auth_mode option:selected').text() ); |
804 |
} |
805 |
|
806 |
function handleTests() { |
807 |
var testOutput = $('#testOutput'); |
808 |
|
809 |
$.ajax({ |
810 |
url: "/api/v1/sftp_server/[% sftp_server.id | html %]/test_connection", |
811 |
}) |
812 |
.done(function(data) { |
813 |
testOutput.text(''); |
814 |
|
815 |
for ( let [key, value] of Object.entries( data ) ) { |
816 |
var title; |
817 |
switch(key) { |
818 |
case '1_sftp_conn': |
819 |
title = _("Testing SFTP connectivity"); |
820 |
break; |
821 |
case '1_ftp_conn': |
822 |
title = _("Testing FTP connectivity"); |
823 |
break; |
824 |
case '2_sftp_ls': |
825 |
case '3_ftp_ls': |
826 |
title = _("Testing FTP connectivity"); |
827 |
break; |
828 |
case '2_ftp_login': |
829 |
title = _("Testing we can log in"); |
830 |
break; |
831 |
case '3_sftp_write': |
832 |
case '4_ftp_write': |
833 |
title = _("Testing we can write a test file"); |
834 |
break; |
835 |
case '4_sftp_del': |
836 |
case '5_ftp_del': |
837 |
title = _("Testing we can delete test file"); |
838 |
break; |
839 |
default: |
840 |
title = key |
841 |
} |
842 |
|
843 |
if ( value.passed ) { |
844 |
testOutput.append( |
845 |
'<i class="text-success fa-solid fa-circle-check"></i> ' |
846 |
+ title |
847 |
+ '... <span class="text-success">' |
848 |
+ _("Passed") |
849 |
+ '</span><br />' |
850 |
); |
851 |
if( value.msg ) testOutput.append( _("Message: ") + '<code>' + value.msg + '</code><br />' ); |
852 |
} else { |
853 |
testOutput.append( |
854 |
'<i class="text-danger fa-solid fa-circle-xmark"></i> ' |
855 |
+ title |
856 |
+ '... <span class="text-danger">' |
857 |
+ _("Failed") |
858 |
+ '</span><br />' |
859 |
); |
860 |
if( value.err ) testOutput.append( _("Error message: ") + '<code>' + value.err + '</code><br />' ); |
861 |
} |
862 |
testOutput.append( '<br />' ); |
863 |
} |
864 |
}) |
865 |
.fail(function(data) { |
866 |
if( data.status == 404 ) { |
867 |
return testOutput.text( '<i class="text-success fa-solid fa-circle-check"></i> ' + _("FTP/SFTP Server not found") ); |
868 |
} else { |
869 |
return testOutput.text( '<i class="text-success fa-solid fa-circle-check"></i> ' + _("Internal Server Error. Please check the server logs") ); |
870 |
} |
871 |
}); |
872 |
} |
873 |
</script> |
874 |
[% END %] |
875 |
|
876 |
[% INCLUDE 'intranet-bottom.inc' %] |