Skip to content

Commit af0e853

Browse files
[#39] Addresses suggestions re iRODS file system setup UX. (#44)
Retrieve and use default labels from system.properties. --------- Co-authored-by: Maciej Kowalski <mKowalski256@users.noreply.github.com>
1 parent 0f0d45f commit af0e853

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

src/main/java/com/researchspace/netfiles/NfsFactory.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
/** Class providing various Net File Store implementations depending on deployment.properties */
2323
@Component
2424
public class NfsFactory {
25+
26+
private static final int IRODS_DEFAULT_PORT = 1247;
2527

2628
private static final Logger log = LoggerFactory.getLogger(NfsFactory.class);
2729

@@ -90,11 +92,7 @@ public NfsClient getNfsClient(String nfsusername, String nfspassword, NfsFileSys
9092
}
9193
if (NfsClientType.IRODS.equals(clientType)) {
9294
int irodsPort;
93-
if (StringUtils.isEmpty(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT))) {
94-
irodsPort = 1247;
95-
} else {
96-
irodsPort = Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT));
97-
}
95+
irodsPort = (StringUtils.isBlank(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT))) ? IRODS_DEFAULT_PORT : Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT));
9896
return new IRODSClient(
9997
new IRODSAccount(
10098
fileSystem.getUrl(),

src/main/webapp/scripts/pages/system/netfilesystem_mod.js

+30-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
define(function() {
22

3+
var sysNetFileSysDetUrl;
4+
var sysNetfileSysDetAuthPasswd;
5+
36
var fileSystemsArray;
47

58
function loadNetFileSystemsList() {
@@ -33,6 +36,7 @@ define(function() {
3336
}
3437

3538
function setFileSystemClientTypeLabels() {
39+
3640
$.each(fileSystemsArray, function(i, fs) {
3741
if (fs.clientType === 'SAMBA') {
3842
fs.clientTypeLabel = 'SMBv1';
@@ -137,7 +141,7 @@ define(function() {
137141
$('#fileSystemDetailsSftpDirChoiceNo').prop('checked', isSftpClient && !fileSystemRequiresUserDirs(fileSystem));
138142

139143
refreshClientTypeRows();
140-
144+
141145
$('#fileSystemName').val(fileSystem.name || "");
142146
$('#fileSystemUrl').val(fileSystem.url || "");
143147

@@ -268,6 +272,15 @@ define(function() {
268272
//therefore we hide the choice from non SFTP clients but we also
269273
//have to give it a value in the UI else the UI framework throws an error on save
270274
function refreshClientTypeRows() {
275+
276+
// retrieve default label values from system.properties
277+
if (sysNetFileSysDetUrl === undefined) {
278+
sysNetFileSysDetUrl = $("label[for='fileSystemUrl']").text();
279+
}
280+
if (sysNetfileSysDetAuthPasswd === undefined) {
281+
sysNetfileSysDetAuthPasswd = $('#fileSystemAuthTypePasswordSpan').text();
282+
}
283+
271284
const isSambaClient = $('#fileSystemClientTypeSamba').prop('checked');
272285
const isSambaSmbjClient = isSambaClient && $('#fileSystemClientTypeSambaSmbj').prop('checked');
273286
const isSftpClient = $('#fileSystemClientTypeSftp').prop('checked');
@@ -296,23 +309,27 @@ define(function() {
296309
if (isSambaClient) {
297310
$('#fileSystemAuthTypePassword').click();
298311
}
299-
312+
300313
if (isSambaClient || isSambaSmbjClient) {
301314
$('#fileSystemUrl')
302315
.attr('title', 'Samba server URL should start with smb://')
303316
.attr('pattern', '^smb://.*');
304-
$("label[for='fileSystemAuthTypePubKey']").show();
317+
$("label[for='fileSystemAuthTypePubKey']").show();
318+
$('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd);
319+
$("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl);
305320
} else if (isIrodsClient) {
306-
$('#fileSystemAuthTypePassword').click();
307-
$('#fileSystemUrl')
308-
.removeAttr('pattern')
309-
.attr('title', 'iRODS hostname or IP without protocol');
310-
$("label[for='fileSystemUrl']").text('iRODS Host');
311-
$("label[for='fileSystemAuthTypePubKey']").hide();
312-
$('#fileSystemAuthTypePasswordSpan').text('Native');
321+
$('#fileSystemAuthTypePassword').click();
322+
$('#fileSystemUrl')
323+
.removeAttr('pattern')
324+
.attr('title', 'iRODS hostname or IP without protocol');
325+
$("label[for='fileSystemUrl']").text('iRODS Host');
326+
$("label[for='fileSystemAuthTypePubKey']").hide();
327+
$('#fileSystemAuthTypePasswordSpan').text('Native');
313328
} else {
314329
$('#fileSystemUrl').removeAttr('title').removeAttr('pattern');
315-
$("label[for='fileSystemAuthTypePubKey']").show();
330+
$("label[for='fileSystemAuthTypePubKey']").show();
331+
$('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd);
332+
$("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl);
316333
}
317334
}
318335

@@ -323,7 +340,8 @@ define(function() {
323340
$('#fileSystemPubKeyRegistrationUrl').prop('required', isPubKeyAuth);
324341
}
325342

326-
$(document).ready(function() {
343+
$(document).ready(function() {
344+
327345
$(document).on('click', '#netFileSystemLink', loadNetFileSystemsList);
328346
$(document).on('click', '.fileSystemDetailsButton', showFileSystemDetails);
329347
$(document).on('click', '.fileSystemDeleteButton', deleteFileSystem);

0 commit comments

Comments
 (0)