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 |
</head> |
20 |
|
21 |
<body id="admin_sftp_servers" class="admin"> |
22 |
[% WRAPPER 'header.inc' %] |
23 |
[% INCLUDE 'prefs-admin-search.inc' %] |
24 |
[% END %] |
25 |
|
26 |
[% WRAPPER 'sub-header.inc' %] |
27 |
[% WRAPPER breadcrumbs %] |
28 |
[% WRAPPER breadcrumb_item %] |
29 |
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> |
30 |
[% END %] |
31 |
|
32 |
[% IF op == 'add_form' || op == 'edit_form' || op == 'test_form' %] |
33 |
[% WRAPPER breadcrumb_item %] |
34 |
<a href="/cgi-bin/koha/admin/sftp_servers.pl">FTP/SFTP servers</a> |
35 |
[% END %] |
36 |
[% END %] |
37 |
|
38 |
[% IF op == 'add_form' %] |
39 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
40 |
<span>New FTP/SFTP server</span> |
41 |
[% END %] |
42 |
|
43 |
[% ELSIF op == 'edit_form' %] |
44 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
45 |
[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
46 |
[% END %] |
47 |
|
48 |
[% ELSIF op == 'test_form' %] |
49 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
50 |
[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %] |
51 |
[% END %] |
52 |
|
53 |
[% ELSE %] |
54 |
[% WRAPPER breadcrumb_item bc_active= 1 %] |
55 |
<span>FTP/SFTP servers</span> |
56 |
[% END %] |
57 |
[% END %] |
58 |
[% END #/ WRAPPER breadcrumbs %] |
59 |
[% END #/ WRAPPER sub-header.inc %] |
60 |
|
61 |
<div class="main container-fluid"> |
62 |
<div class="row"> |
63 |
<div class="col-md-10 order-md-2 order-sm-1"> |
64 |
<main> |
65 |
[% INCLUDE 'messages.inc' %] |
66 |
|
67 |
[% FOREACH m IN messages %] |
68 |
<div class="alert alert-[% m.type | html %]" id="sftp_action_result_dialog"> |
69 |
[% SWITCH m.code %] |
70 |
[% CASE 'error_on_insert' %] |
71 |
<span>An error occurred when adding the server. The passed ID already exists.</span> |
72 |
[% CASE 'error_on_update' %] |
73 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
74 |
[% CASE 'error_on_edit' %] |
75 |
<span>An error occurred trying to open the server for editing. The passed ID is invalid.</span> |
76 |
[% CASE 'error_on_test' %] |
77 |
<span>An error occurred when connecting to this server. Please see the text below for more information.</span> |
78 |
[% CASE 'success_on_update' %] |
79 |
<span>Server updated successfully.</span> |
80 |
[% CASE 'success_on_insert' %] |
81 |
<span>Server added successfully.</span> |
82 |
[% CASE %] |
83 |
<span>[% m.code | html %]</span> |
84 |
[% END %] |
85 |
</div> |
86 |
[% END %] |
87 |
|
88 |
<div class="alert alert-info" id="sftp_delete_success" style="display: none;"></div> |
89 |
<div class="alert alert-warning" id="sftp_delete_error" style="display: none;"></div> |
90 |
|
91 |
[% IF op == 'add_form' %] |
92 |
<!-- Modal --> |
93 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
94 |
<div class="modal-dialog modal-lg"> |
95 |
<div class="modal-content modal-lg"> |
96 |
<div class="modal-header"> |
97 |
<h1 class="modal-title">Are you sure?</h1> |
98 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
99 |
</div> |
100 |
<div class="modal-body"> |
101 |
<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> |
102 |
<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> |
103 |
<table class="mx-4 mb-3"> |
104 |
<thead></thead> |
105 |
<tbody> |
106 |
<tr> |
107 |
<td><strong>Host</strong></td> |
108 |
<td id="modal_host"></td> |
109 |
</tr> |
110 |
<tr> |
111 |
<td><strong>Port</strong></td> |
112 |
<td id="modal_port"></td> |
113 |
</tr> |
114 |
<tr> |
115 |
<td><strong>Transport</strong></td> |
116 |
<td id="modal_transport"></td> |
117 |
</tr> |
118 |
<tr> |
119 |
<td><strong>Username</strong></td> |
120 |
<td id="modal_user_name"></td> |
121 |
</tr> |
122 |
<tr> |
123 |
<td><strong>Authentication mode</strong></td> |
124 |
<td id="modal_auth_mode"></td> |
125 |
</tr> |
126 |
</tbody> |
127 |
</table> |
128 |
<p>If you are ready to progress with these details, please click Save.</p> |
129 |
</div> |
130 |
<div class="modal-footer"> |
131 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
132 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
133 |
</div> |
134 |
</form> |
135 |
</div> |
136 |
</div> |
137 |
</div> |
138 |
<!-- END Modal --> |
139 |
|
140 |
<h1>New FTP/SFTP server</h1> |
141 |
|
142 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="add" name="add" class="validated" method="post"> |
143 |
[% INCLUDE 'csrf-token.inc' %] |
144 |
<input type="hidden" name="op" value="cud-add" /> |
145 |
<fieldset class="rows"> |
146 |
<ol> |
147 |
<li> |
148 |
<label for="sftp_name" class="required">Name: </label> |
149 |
<input type="text" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
150 |
<span class="required">Required</span> |
151 |
</li> |
152 |
</ol> |
153 |
</fieldset> |
154 |
|
155 |
<fieldset class="rows"> |
156 |
<ol> |
157 |
<li> |
158 |
<label for="sftp_host" class="required">Host: </label> |
159 |
<input type="text" value="localhost" name="sftp_host" id="sftp_host" size="60" class="required" /> |
160 |
<span class="required">Required</span> |
161 |
</li> |
162 |
<li> |
163 |
<label for="sftp_port" class="required">Port: </label> |
164 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="22" name="sftp_port" id="sftp_port" size="20" class="required" /> |
165 |
<span class="required">Required</span> |
166 |
</li> |
167 |
<li> |
168 |
<label for="sftp_transport" class="required">Transport: </label> |
169 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
170 |
<option value="ftp">FTP</option> |
171 |
<option value="sftp" selected="selected">SFTP</option> |
172 |
</select> |
173 |
<span class="required">Required</span> |
174 |
</li> |
175 |
<li> |
176 |
<label for="sftp_passiv">Passive mode: </label> |
177 |
<select name="sftp_passiv" id="sftp_passiv" disabled="disabled"> |
178 |
<option value="1" selected="selected">On (Recommended)</option> |
179 |
<option value="0">Off</option> |
180 |
</select> |
181 |
<span class="hint">Only applies to FTP connections</span> |
182 |
</li> |
183 |
<li> |
184 |
<label for="sftp_auth_mode">Authentication mode: </label> |
185 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
186 |
<option value="password" selected="selected">Password-based</option> |
187 |
<option value="key_file">Key file-based</option> |
188 |
<option value="noauth">No authentication</option> |
189 |
</select> |
190 |
</li> |
191 |
<li> |
192 |
<label for="sftp_user_name" class="required">Username: </label> |
193 |
<input type="text" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
194 |
<span class="required">Required</span> |
195 |
</li> |
196 |
<li> |
197 |
<label for="sftp_password">Password: </label> |
198 |
<input type="password" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
199 |
</li> |
200 |
<li> |
201 |
<label for="sftp_key_file">Key file: </label> |
202 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58"></textarea> |
203 |
<span class="hint">Only applies to SFTP connections</span> |
204 |
</li> |
205 |
<li> |
206 |
<label for="sftp_debug_mode">Debug mode: </label> |
207 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
208 |
<option value="1">Enabled</option> |
209 |
<option value="0" selected="selected">Disabled</option> |
210 |
</select> |
211 |
<span class="hint">Enables additional debug output in the logs</span> |
212 |
</li> |
213 |
</ol> |
214 |
</fieldset> |
215 |
<fieldset class="action"> |
216 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
217 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
218 |
</fieldset> |
219 |
</form> |
220 |
[% END %] |
221 |
|
222 |
[% IF op == 'edit_form' && !messages %] |
223 |
<!-- Modal --> |
224 |
<div id="confirm_key_accept" class="modal" tabindex="-1" role="dialog" aria-labelledby="confirm_key_accept_submit" aria-hidden="true"> |
225 |
<div class="modal-dialog modal-lg"> |
226 |
<div class="modal-content modal-lg"> |
227 |
<div class="modal-header"> |
228 |
<h1 class="modal-title">Are you sure?</h1> |
229 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
230 |
</div> |
231 |
<div class="modal-body"> |
232 |
<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> |
233 |
<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> |
234 |
<table class="mx-4 mb-3"> |
235 |
<thead></thead> |
236 |
<tbody> |
237 |
<tr> |
238 |
<td><strong>Host</strong></td> |
239 |
<td id="modal_host"></td> |
240 |
</tr> |
241 |
<tr> |
242 |
<td><strong>Port</strong></td> |
243 |
<td id="modal_port"></td> |
244 |
</tr> |
245 |
<tr> |
246 |
<td><strong>Transport</strong></td> |
247 |
<td id="modal_transport"></td> |
248 |
</tr> |
249 |
<tr> |
250 |
<td><strong>Username</strong></td> |
251 |
<td id="modal_user_name"></td> |
252 |
</tr> |
253 |
<tr> |
254 |
<td><strong>Authentication mode</strong></td> |
255 |
<td id="modal_auth_mode"></td> |
256 |
</tr> |
257 |
</tbody> |
258 |
</table> |
259 |
<p>If you are ready to progress with these details, please click Save.</p> |
260 |
</div> |
261 |
<div class="modal-footer"> |
262 |
<button class="btn btn-default approve" type="submit"><i class="fa fa-check"></i> Save</button> |
263 |
<button class="btn btn-default deny cancel" type="button" data-bs-dismiss="modal"><i class="fa fa-times"></i> Cancel</button> |
264 |
</div> |
265 |
</form> |
266 |
</div> |
267 |
</div> |
268 |
</div> |
269 |
<!-- END Modal --> |
270 |
|
271 |
<h1>[% tx("Modify FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
272 |
|
273 |
<form action="/cgi-bin/koha/admin/sftp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
274 |
[% INCLUDE 'csrf-token.inc' %] |
275 |
<input type="hidden" name="op" value="cud-edit_save" /> |
276 |
<input type="hidden" name="sftp_server_id" value="[%- sftp_server.id | html -%]" /> |
277 |
<fieldset class="rows"> |
278 |
<ol> |
279 |
<li> |
280 |
<label for="sftp_name" class="required">Name: </label> |
281 |
<input type="text" value="[% sftp_server.name | html %]" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" /> |
282 |
<span class="required">Required</span> |
283 |
</li> |
284 |
</ol> |
285 |
</fieldset> |
286 |
|
287 |
<fieldset class="rows"> |
288 |
<ol> |
289 |
<li> |
290 |
<label for="sftp_host" class="required">Host: </label> |
291 |
<input type="text" value="[% sftp_server.host | html %]" name="sftp_host" id="sftp_host" size="60" class="required" /> |
292 |
<span class="required">Required</span> |
293 |
</li> |
294 |
<li> |
295 |
<label for="sftp_port" class="required">Port: </label> |
296 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="[% sftp_server.port | html %]" name="sftp_port" id="sftp_port" size="20" class="required"/> |
297 |
<span class="required">Required</span> |
298 |
</li> |
299 |
<li> |
300 |
<label for="sftp_transport" class="required">Transport: </label> |
301 |
<select name="sftp_transport" id="sftp_transport" class="required"> |
302 |
[% IF sftp_server.transport == 'ftp' %] |
303 |
<option value="ftp" selected="selected">FTP</option> |
304 |
[% ELSE %] |
305 |
<option value="ftp">FTP</option> |
306 |
[% END %] |
307 |
[% IF sftp_server.transport == 'sftp' %] |
308 |
<option value="sftp" selected="selected">SFTP</option> |
309 |
[% ELSE %] |
310 |
<option value="sftp">SFTP</option> |
311 |
[% END %] |
312 |
</select> |
313 |
<span class="required">Required</span> |
314 |
</li> |
315 |
<li> |
316 |
<label for="sftp_passiv">Passive mode: </label> |
317 |
<select name="sftp_passiv" id="sftp_passiv" disabled="disabled"> |
318 |
[% IF sftp_server.passiv == 1 %] |
319 |
<option value="1" selected="selected">Enabled (Recommended)</option> |
320 |
[% ELSE %] |
321 |
<option value="1">Enabled (Recommended)</option> |
322 |
[% END %] |
323 |
[% IF sftp_server.passiv == 0 %] |
324 |
<option value="0" selected="selected">Disabled</option> |
325 |
[% ELSE %] |
326 |
<option value="0">Disabled</option> |
327 |
[% END %] |
328 |
</select> |
329 |
<span class="hint">Only applies to FTP connections</span> |
330 |
</li> |
331 |
<li> |
332 |
<label for="sftp_auth_mode">Authentication mode: </label> |
333 |
<select name="sftp_auth_mode" id="sftp_auth_mode"> |
334 |
[% IF sftp_server.auth_mode == 'password' %] |
335 |
<option value="password" selected="selected">Password-based</option> |
336 |
[% ELSE %] |
337 |
option value="password">Password-based</option> |
338 |
[% END %] |
339 |
[% IF sftp_server.auth_mode == 'key_file' %] |
340 |
<option value="key_file" selected="selected">Key file-based</option> |
341 |
[% ELSE %] |
342 |
<option value="key_file">Key file-based</option> |
343 |
[% END %] |
344 |
[% IF sftp_server.auth_mode == 'noauth' %] |
345 |
<option value="noauth" selected="selected">No authentication</option> |
346 |
[% ELSE %] |
347 |
<option value="noauth">No authentication</option> |
348 |
[% END %] |
349 |
</select> |
350 |
</li> |
351 |
<li> |
352 |
<label for="sftp_user_name" class="required">Username: </label> |
353 |
<input type="text" value="[% sftp_server.user_name | html %]" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" /> |
354 |
<span class="required">Required</span> |
355 |
</li> |
356 |
<li> |
357 |
<label for="sftp_password">Password: </label> |
358 |
<input type="password" value="[% sftp_server_plain_text_password | html %]" name="sftp_password" id="sftp_password" size="60" autocomplete="off" /> |
359 |
</li> |
360 |
<li> |
361 |
<label for="sftp_key_file">Key file path: </label> |
362 |
<textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58">[% sftp_server_plain_text_key | html %]</textarea> |
363 |
<span class="hint">Only applies to SFTP connections</span> |
364 |
</li> |
365 |
<li> |
366 |
<label for="sftp_debug_mode">Debug mode: </label> |
367 |
<select name="sftp_debug_mode" id="sftp_debug_mode"> |
368 |
[% IF sftp_server.debug == 1 %] |
369 |
<option value="1" selected="selected">Enabled</option> |
370 |
[% ELSE %] |
371 |
<option value="1">Enabled</option> |
372 |
[% END %] |
373 |
[% IF sftp_server.debug == 0 %] |
374 |
<option value="0" selected="selected">Disabled</option> |
375 |
[% ELSE %] |
376 |
<option value="0">Disabled</option> |
377 |
[% END %] |
378 |
</select> |
379 |
<span class="hint">Enables additional debug output in the logs</span> |
380 |
</li> |
381 |
</ol> |
382 |
</fieldset> |
383 |
<fieldset class="action"> |
384 |
<a id="confirm_key_accept_submit" data-bs-target="#confirm_key_accept" class="btn btn-primary" data-bs-toggle="modal">Submit</a> |
385 |
<a class="cancel" href="/cgi-bin/koha/admin/sftp_servers.pl">Cancel</a> |
386 |
</fieldset> |
387 |
</form> |
388 |
[% END %] |
389 |
|
390 |
[% IF op == 'test_form' %] |
391 |
<div id="toolbar" class="btn-toolbar"> |
392 |
<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> |
393 |
</div> |
394 |
<h1>[% tx("Test FTP/SFTP server '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1> |
395 |
<div class="page-section"> |
396 |
<pre>>> Testing the FTP/SFTP server for you</pre> |
397 |
<pre>>> Connection details will be as follows:</pre> |
398 |
<pre>Transport: [% sftp_server.transport FILTER upper | html %]</pre> |
399 |
<pre>Username: [% sftp_server.user_name | html %]</pre> |
400 |
<pre>Host: [% sftp_server.host | html %]</pre> |
401 |
<pre>Port: [% sftp_server.port | html %]</pre> |
402 |
<pre>>> Okay, starting tests . . . </pre> |
403 |
[% FOREACH result IN sftp_server_test_result.pairs %] |
404 |
<pre>=================================================</pre> |
405 |
[% SWITCH result.key %] |
406 |
[% CASE '1_sftp_conn' %] |
407 |
<pre>>> Testing SFTP connecivity</pre> |
408 |
[% CASE '1_ftp_conn' %] |
409 |
<pre>>> Testing FTP connecivity</pre> |
410 |
[% CASE ['2_sftp_ls', '3_ftp_ls'] %] |
411 |
<pre>>> Testing we can list directories</pre> |
412 |
[% CASE '2_ftp_login' %] |
413 |
<pre>>> Testing we can log in</pre> |
414 |
[% CASE ['3_sftp_write', '4_ftp_write'] %] |
415 |
<pre>>> Testing we can write a test file</pre> |
416 |
[% CASE ['4_sftp_del', '5_ftp_del'] %] |
417 |
<pre>>> Testing we can delete test file</pre> |
418 |
[% CASE DEFAULT %] |
419 |
<pre>>> [% result.key | html %]</pre> |
420 |
[% END %] |
421 |
<pre>Executing [% result.key | html %] test . . . </pre> |
422 |
[% IF ( result.value.err ) %] |
423 |
<pre>ERROR: [% result.value.err | html %]</pre> |
424 |
[% ELSE %] |
425 |
[% IF ( result.value.msg ) %] |
426 |
<pre>PASSED: [% result.value.msg | html %]</pre> |
427 |
[% ELSE %] |
428 |
<pre>PASSED</pre> |
429 |
[% END %] |
430 |
[% END %] |
431 |
[% END %] |
432 |
<pre>=================================================</pre> |
433 |
</div> |
434 |
[% END %] |
435 |
|
436 |
[% IF op == 'list' %] |
437 |
|
438 |
<div id="toolbar" class="btn-toolbar"> |
439 |
<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> |
440 |
</div> |
441 |
|
442 |
<h1>FTP/SFTP servers</h1> |
443 |
|
444 |
[% IF servers_count < 1 %] |
445 |
<div class="alert alert-info" id="dno_servers_message"> |
446 |
<p> |
447 |
<em>There are no FTP/SFTP servers defined.</em><br /> |
448 |
To create one, use the <strong>new FTP/SFTP server</strong> button above. |
449 |
</p> |
450 |
</div> |
451 |
[% ELSE %] |
452 |
<div class="page-section"> |
453 |
<table id="sftp_servers"> |
454 |
<thead> |
455 |
<tr> |
456 |
<th>Name</th> |
457 |
<th>Host</th> |
458 |
<th>Port</th> |
459 |
<th>Transport</th> |
460 |
<th>Passive mode</th> |
461 |
<th>Authentication mode</th> |
462 |
<th>Username</th> |
463 |
<th>Debug</th> |
464 |
<th data-class-name="actions noExport">Actions</th> |
465 |
</tr> |
466 |
</thead> |
467 |
</table> |
468 |
</div> <!-- /.page-section --> |
469 |
[% END %] |
470 |
[% END %] |
471 |
|
472 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
473 |
<div class="modal-dialog"> |
474 |
<div class="modal-content"> |
475 |
<div class="modal-header"> |
476 |
<h1 class="modal-title" id="delete_confirm_modal_label">Delete server</h1> |
477 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
478 |
</div> |
479 |
<div class="modal-body"> |
480 |
<div id="delete_confirm_dialog"></div> |
481 |
</div> |
482 |
<div class="modal-footer"> |
483 |
<button type="button" class="btn btn-danger" id="delete_confirm_modal_button" data-bs-toggle="modal">Delete</button> |
484 |
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button> |
485 |
</div> |
486 |
</div> <!-- /.modal-content --> |
487 |
</div> <!-- /.modal-dialog --> |
488 |
</div> <!-- #delete_confirm_modal --> |
489 |
|
490 |
</main> |
491 |
</div> <!-- /.col-md-10.order-md-2 --> |
492 |
|
493 |
<div class="col-md-2 order-sm-2 order-md-1"> |
494 |
<aside> |
495 |
[% INCLUDE 'admin-menu.inc' %] |
496 |
</aside> |
497 |
</div> <!-- /.col-md-2.order-md-1 --> |
498 |
</div> <!-- /.row --> |
499 |
|
500 |
|
501 |
[% MACRO jsinclude BLOCK %] |
502 |
[% Asset.js("js/admin-menu.js") | $raw %] |
503 |
[% INCLUDE 'datatables.inc' %] |
504 |
<script> |
505 |
$(document).ready(function() { |
506 |
|
507 |
var sftp_servers_url = '/api/v1/config/sftp_servers'; |
508 |
window.sftp_servers = $("#sftp_servers").kohaTable({ |
509 |
"ajax": { |
510 |
"url": sftp_servers_url |
511 |
}, |
512 |
'language': { |
513 |
'emptyTable': '<div class="alert alert-info">'+_("There are no FTP/SFTP servers defined.")+'</div>' |
514 |
}, |
515 |
"columnDefs": [ { |
516 |
"targets": [0,1], |
517 |
"render": function(data, type, row, meta) { |
518 |
if(type == 'display') { |
519 |
if(data != null) { |
520 |
return data.escapeHtml(); |
521 |
} |
522 |
else { |
523 |
return "Default"; |
524 |
} |
525 |
} |
526 |
return data; |
527 |
} |
528 |
} ], |
529 |
"columns": [ |
530 |
{ |
531 |
"data": "name", |
532 |
"searchable": true, |
533 |
"orderable": true |
534 |
}, |
535 |
{ |
536 |
"data": "host", |
537 |
"searchable": true, |
538 |
"orderable": true |
539 |
}, |
540 |
{ |
541 |
"data": "port", |
542 |
"searchable": true, |
543 |
"orderable": false |
544 |
}, |
545 |
{ |
546 |
"data": "transport", |
547 |
"render": function(data, type, row, meta) { |
548 |
return data.toUpperCase(); |
549 |
}, |
550 |
"searchable": true, |
551 |
"orderable": false |
552 |
}, |
553 |
{ |
554 |
"data": "passiv", |
555 |
"render": function(data, type, row, meta) { |
556 |
if(data == true) { |
557 |
return "[% tp("Active", "On") | html %]"; |
558 |
} |
559 |
else { |
560 |
return _("Off"); |
561 |
} |
562 |
}, |
563 |
"searchable": false, |
564 |
"orderable": false |
565 |
}, |
566 |
{ |
567 |
"data": "auth_mode", |
568 |
"render": function(data, type, row, meta) { |
569 |
if(data == "password") { |
570 |
return _("Password-based"); |
571 |
} |
572 |
else if(data == "key_file") { |
573 |
return _("Key file-based"); |
574 |
} |
575 |
else { |
576 |
return _("No authentication"); |
577 |
} |
578 |
}, |
579 |
"searchable": false, |
580 |
"orderable": false |
581 |
}, |
582 |
{ |
583 |
"data": "user_name", |
584 |
"searchable": false, |
585 |
"orderable": false |
586 |
}, |
587 |
{ |
588 |
"data": "debug", |
589 |
"render": function(data, type, row, meta) { |
590 |
if(data == true) { |
591 |
return "[% tp("Active", "On") | html %]"; |
592 |
} |
593 |
else { |
594 |
return _("Off"); |
595 |
} |
596 |
}, |
597 |
"searchable": false, |
598 |
"orderable": false |
599 |
}, |
600 |
{ |
601 |
"data": function(row, type, val, meta) { |
602 |
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"; |
603 |
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"; |
604 |
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>'; |
605 |
return result; |
606 |
}, |
607 |
"searchable": false, |
608 |
"orderable": false |
609 |
} |
610 |
], |
611 |
createdRow: function(row, data, dataIndex) { |
612 |
if(data.is_default) { |
613 |
$(row).addClass('default warn'); |
614 |
} |
615 |
if(data.debug) { |
616 |
$(row).addClass('debug'); |
617 |
} |
618 |
}, |
619 |
}); |
620 |
|
621 |
$('#sftp_servers').on("click", '.delete_server', function() { |
622 |
var sftp_server_id = $(this).data('sftp-server-id'); |
623 |
var sftp_server_name = decodeURIComponent($(this).data('sftp-server-name')); |
624 |
|
625 |
$("#delete_confirm_dialog").html( |
626 |
_("You are about to delete the '%s' FTP/SFTP server.").format(sftp_server_name) |
627 |
); |
628 |
$("#delete_confirm_modal_button").data('sftp-server-id', sftp_server_id); |
629 |
$("#delete_confirm_modal_button").data('sftp-server-name', sftp_server_name); |
630 |
}); |
631 |
|
632 |
$("#delete_confirm_modal_button").on("click", function() { |
633 |
|
634 |
var sftp_server_id = $(this).data('sftp-server-id'); |
635 |
var sftp_server_name = $(this).data('sftp-server-name'); |
636 |
|
637 |
$.ajax({ |
638 |
method: "DELETE", |
639 |
url: "/api/v1/config/sftp_servers/"+sftp_server_id |
640 |
}).success(function() { |
641 |
window.sftp_servers.api().ajax.reload(function(data) { |
642 |
$("#sftp_action_result_dialog").hide(); |
643 |
$("#sftp_delete_success").html(_("Server '%s' deleted successfully.").format(sftp_server_name)).show(); |
644 |
}); |
645 |
}).fail(function() { |
646 |
$("#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(); |
647 |
}).done(function() { |
648 |
$("#delete_confirm_modal").modal('hide'); |
649 |
}); |
650 |
}); |
651 |
|
652 |
// run transportChange on pageload, and again every time sftp_transport changes |
653 |
transportChange(); |
654 |
$("#sftp_transport").on("change", function(event) { |
655 |
transportChange(); |
656 |
}); |
657 |
|
658 |
// run authModeChange on pageload, and again every time sftp_auth_mode changes |
659 |
authModeChange(); |
660 |
$("#sftp_auth_mode").on("change", function(event) { |
661 |
authModeChange(); |
662 |
}); |
663 |
|
664 |
$('#confirm_key_accept_submit').on('click', function(event) { |
665 |
event.preventDefault(); |
666 |
|
667 |
if ( $('#add').length > 0 ) { // has to be nested to avoid errors :-( |
668 |
if( $('#add').valid() == true ) { |
669 |
modalChange(); |
670 |
$('#confirm_key_accept').modal('show'); |
671 |
} else { |
672 |
$('#confirm_key_accept').modal('hide'); |
673 |
} |
674 |
} |
675 |
|
676 |
if ( $('#edit_save').length > 0 ) { // has to be nested to avoid errors :-( |
677 |
if( $('#edit_save').valid() == true ) { |
678 |
modalChange(); |
679 |
$('#confirm_key_accept').modal('show'); |
680 |
} else { |
681 |
$('#confirm_key_accept').modal('hide'); |
682 |
} |
683 |
} |
684 |
|
685 |
}); |
686 |
|
687 |
$('#confirm_key_accept .approve').on('click', function() { |
688 |
$('#confirm_key_accept .deny').click(); |
689 |
|
690 |
if ( $('#add').length > 0 ) { |
691 |
$('#add').submit(); |
692 |
} |
693 |
|
694 |
if ( $('#edit_save').length > 0 ) { |
695 |
$('#edit_save').submit(); |
696 |
} |
697 |
}); |
698 |
|
699 |
}); |
700 |
|
701 |
function transportChange() { |
702 |
let sftp_transport = $("#sftp_transport"); |
703 |
|
704 |
if(sftp_transport.val() == "ftp") { |
705 |
// disable / enable relevant options |
706 |
$("#sftp_host").removeAttr("disabled"); |
707 |
$("#sftp_port").removeAttr("disabled"); |
708 |
$("#sftp_passiv").removeAttr("disabled"); |
709 |
$("#sftp_auth_mode").removeAttr("disabled"); |
710 |
$("#sftp_user_name").removeAttr("disabled"); |
711 |
$("#sftp_password").removeAttr("disabled"); |
712 |
$("#sftp_key_file").attr("disabled", "disabled"); |
713 |
|
714 |
// ... for auth_mode dropdown |
715 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
716 |
$("#sftp_auth_mode option[value='key_file']").attr("disabled", "disabled"); |
717 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
718 |
// also reset the selected value CONDITIONALLY |
719 |
if($("#sftp_auth_mode option:selected").val() == "key_file") { |
720 |
$("#sftp_auth_mode option[value='password']").prop("selected", true); |
721 |
} |
722 |
|
723 |
// check the port |
724 |
let sftp_port = $("#sftp_port").val(); |
725 |
if(sftp_port == 22) $("#sftp_port").val("21"); |
726 |
|
727 |
// trigger authModeChange so the auth fields are correct |
728 |
authModeChange(); |
729 |
} else if(sftp_transport.val() == "sftp") { |
730 |
// disable / enable relevant options |
731 |
$("#sftp_host").removeAttr("disabled"); |
732 |
$("#sftp_port").removeAttr("disabled"); |
733 |
$("#sftp_passiv").attr("disabled", "disabled"); |
734 |
$("#sftp_auth_mode").removeAttr("disabled"); |
735 |
$("#sftp_user_name").removeAttr("disabled"); |
736 |
$("#sftp_password").removeAttr("disabled"); |
737 |
$("#sftp_key_file").removeAttr("disabled"); |
738 |
|
739 |
// ... for auth_mode dropdown |
740 |
$("#sftp_auth_mode option[value='password']").removeAttr("disabled"); |
741 |
$("#sftp_auth_mode option[value='key_file']").removeAttr("disabled"); |
742 |
$("#sftp_auth_mode option[value='noauth']").removeAttr("disabled"); |
743 |
// also reset the selected value CONDITIONALLY |
744 |
$("#sftp_passiv option[value='1']").prop("selected", true); |
745 |
|
746 |
// check the port |
747 |
let sftp_port = $("#sftp_port").val(); |
748 |
if(sftp_port == 21) $("#sftp_port").val("22"); |
749 |
|
750 |
// trigger authModeChange so the auth fields are correct |
751 |
return authModeChange(); |
752 |
} |
753 |
} |
754 |
|
755 |
function authModeChange() { |
756 |
let sftp_auth_mode = $("#sftp_auth_mode").val(); |
757 |
|
758 |
if(sftp_auth_mode == "password") { |
759 |
// disable / enable relevant options |
760 |
$("#sftp_password").removeAttr("disabled"); |
761 |
$("#sftp_key_file").attr("disabled", "disabled"); |
762 |
} else if(sftp_auth_mode == "key_file") { |
763 |
// disable / enable relevant options |
764 |
$("#sftp_password").attr("disabled", "disabled"); |
765 |
$("#sftp_key_file").removeAttr("disabled"); |
766 |
} else { |
767 |
// disable / enable relevant options |
768 |
$("#sftp_password").attr("disabled", "disabled"); |
769 |
$("#sftp_key_file").attr("disabled", "disabled"); |
770 |
} |
771 |
} |
772 |
|
773 |
function modalChange() { |
774 |
// should we show the sftp warning? |
775 |
$('#modal_message').hide(); |
776 |
if ( $('#sftp_transport').val() == 'sftp' ) $('#modal_message').show(); |
777 |
|
778 |
// populate modal |
779 |
$('#modal_host').text( $('#sftp_host').val() ); |
780 |
$('#modal_port').text( $('#sftp_port').val() ); |
781 |
$('#modal_transport').text( $('#sftp_transport option:selected').text() ); |
782 |
$('#modal_user_name').text( $('#sftp_user_name').val() ); |
783 |
$('#modal_auth_mode').text( $('#sftp_auth_mode option:selected').text() ); |
784 |
} |
785 |
</script> |
786 |
[% END %] |
787 |
|
788 |
[% INCLUDE 'intranet-bottom.inc' %] |