Skip to content

Commit

Permalink
[#39] Addresses suggestions re iRODS file system setup UX. (#44)
Browse files Browse the repository at this point in the history
Retrieve and use default labels from system.properties.

---------

Co-authored-by: Maciej Kowalski <[email protected]>
  • Loading branch information
ll4strw and mKowalski256 authored Aug 15, 2024
1 parent 0f0d45f commit af0e853
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/researchspace/netfiles/NfsFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/** Class providing various Net File Store implementations depending on deployment.properties */
@Component
public class NfsFactory {

private static final int IRODS_DEFAULT_PORT = 1247;

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

Expand Down Expand Up @@ -90,11 +92,7 @@ public NfsClient getNfsClient(String nfsusername, String nfspassword, NfsFileSys
}
if (NfsClientType.IRODS.equals(clientType)) {
int irodsPort;
if (StringUtils.isEmpty(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT))) {
irodsPort = 1247;
} else {
irodsPort = Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT));
}
irodsPort = (StringUtils.isBlank(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT))) ? IRODS_DEFAULT_PORT : Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT));
return new IRODSClient(
new IRODSAccount(
fileSystem.getUrl(),
Expand Down
42 changes: 30 additions & 12 deletions src/main/webapp/scripts/pages/system/netfilesystem_mod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
define(function() {

var sysNetFileSysDetUrl;
var sysNetfileSysDetAuthPasswd;

var fileSystemsArray;

function loadNetFileSystemsList() {
Expand Down Expand Up @@ -33,6 +36,7 @@ define(function() {
}

function setFileSystemClientTypeLabels() {

$.each(fileSystemsArray, function(i, fs) {
if (fs.clientType === 'SAMBA') {
fs.clientTypeLabel = 'SMBv1';
Expand Down Expand Up @@ -137,7 +141,7 @@ define(function() {
$('#fileSystemDetailsSftpDirChoiceNo').prop('checked', isSftpClient && !fileSystemRequiresUserDirs(fileSystem));

refreshClientTypeRows();

$('#fileSystemName').val(fileSystem.name || "");
$('#fileSystemUrl').val(fileSystem.url || "");

Expand Down Expand Up @@ -268,6 +272,15 @@ define(function() {
//therefore we hide the choice from non SFTP clients but we also
//have to give it a value in the UI else the UI framework throws an error on save
function refreshClientTypeRows() {

// retrieve default label values from system.properties
if (sysNetFileSysDetUrl === undefined) {
sysNetFileSysDetUrl = $("label[for='fileSystemUrl']").text();
}
if (sysNetfileSysDetAuthPasswd === undefined) {
sysNetfileSysDetAuthPasswd = $('#fileSystemAuthTypePasswordSpan').text();
}

const isSambaClient = $('#fileSystemClientTypeSamba').prop('checked');
const isSambaSmbjClient = isSambaClient && $('#fileSystemClientTypeSambaSmbj').prop('checked');
const isSftpClient = $('#fileSystemClientTypeSftp').prop('checked');
Expand Down Expand Up @@ -296,23 +309,27 @@ define(function() {
if (isSambaClient) {
$('#fileSystemAuthTypePassword').click();
}

if (isSambaClient || isSambaSmbjClient) {
$('#fileSystemUrl')
.attr('title', 'Samba server URL should start with smb://')
.attr('pattern', '^smb://.*');
$("label[for='fileSystemAuthTypePubKey']").show();
$("label[for='fileSystemAuthTypePubKey']").show();
$('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd);
$("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl);
} else if (isIrodsClient) {
$('#fileSystemAuthTypePassword').click();
$('#fileSystemUrl')
.removeAttr('pattern')
.attr('title', 'iRODS hostname or IP without protocol');
$("label[for='fileSystemUrl']").text('iRODS Host');
$("label[for='fileSystemAuthTypePubKey']").hide();
$('#fileSystemAuthTypePasswordSpan').text('Native');
$('#fileSystemAuthTypePassword').click();
$('#fileSystemUrl')
.removeAttr('pattern')
.attr('title', 'iRODS hostname or IP without protocol');
$("label[for='fileSystemUrl']").text('iRODS Host');
$("label[for='fileSystemAuthTypePubKey']").hide();
$('#fileSystemAuthTypePasswordSpan').text('Native');
} else {
$('#fileSystemUrl').removeAttr('title').removeAttr('pattern');
$("label[for='fileSystemAuthTypePubKey']").show();
$("label[for='fileSystemAuthTypePubKey']").show();
$('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd);
$("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl);
}
}

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

$(document).ready(function() {
$(document).ready(function() {

$(document).on('click', '#netFileSystemLink', loadNetFileSystemsList);
$(document).on('click', '.fileSystemDetailsButton', showFileSystemDetails);
$(document).on('click', '.fileSystemDeleteButton', deleteFileSystem);
Expand Down

0 comments on commit af0e853

Please sign in to comment.