Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[39] Addresses suggestions re iRODS file system setup UX #40

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion 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 @@ -89,10 +91,12 @@ public NfsClient getNfsClient(String nfsusername, String nfspassword, NfsFileSys
fileSystem.getClientOption(NfsFileSystemOption.SFTP_SERVER_PUBLIC_KEY));
}
if (NfsClientType.IRODS.equals(clientType)) {
int irodsPort;
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(),
Integer.parseInt(fileSystem.getClientOption(NfsFileSystemOption.IRODS_PORT)),
irodsPort,
nfsusername,
nfspassword,
fileSystem.getClientOption(NfsFileSystemOption.IRODS_HOME_DIR),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bundles/system/system.properties
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ system.netfilesystem.details.client.sftp.server.public.key=SFTP server public ke
system.netfilesystem.details.client.sftp.server.dir.choice=User subdirectory required
system.netfilesystem.details.client.irods=iRODS
system.netfilesystem.details.client.irods.zone=iRODS Zone
system.netfilesystem.details.client.irods.homedir=Home Directory
system.netfilesystem.details.client.irods.homedir=iRODS Search Path
system.netfilesystem.details.client.irods.port= iRODS Port
system.netfilesystem.details.auth=Authentication Type
system.netfilesystem.details.auth.password=Username/Password
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/WEB-INF/pages/system/netfilesystem_ajax.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@
<tr class="fileSystemDetailsIrodsZoneRow">
<td><label for="fileSystemIrodsZone">
<spring:message code="system.netfilesystem.details.client.irods.zone" /></label></td>
<td><input id="fileSystemIrodsZone" type="text" style="width: 20em" /></td>
<td><input id="fileSystemIrodsZone" type="text" style="width: 20em" required/></td>
</tr>
<tr class="fileSystemDetailsIrodsHomeDirRow">
<td><label for="fileSystemIrodsHomeDir">
<spring:message code="system.netfilesystem.details.client.irods.homedir" /></label></td>
<td><input id="fileSystemIrodsHomeDir" type="text" style="width: 20em" /></td>
<td><input id="fileSystemIrodsHomeDir" type="text" style="width: 20em" required/></td>
</tr>
<tr class="fileSystemDetailsIrodsPortRow">
<td><label for="fileSystemIrodsPort">
Expand All @@ -152,8 +152,8 @@
<td><label><spring:message code="system.netfilesystem.details.auth" /></label></td>
<td>
<label><input type="radio" id="fileSystemAuthTypePassword" name="fileSystemAuthType" value="PASSWORD" required>
<spring:message code="system.netfilesystem.details.auth.password" /></label>
<label><input type="radio" id="fileSystemAuthTypePubKey" name="fileSystemAuthType" value="PUBKEY">
<span id="fileSystemAuthTypePasswordSpan"><spring:message code="system.netfilesystem.details.auth.password" /></span></label>
<label for="fileSystemAuthTypePubKey"><input type="radio" id="fileSystemAuthTypePubKey" name="fileSystemAuthType" value="PUBKEY">
<spring:message code="system.netfilesystem.details.auth.pubkey" /></label>
</td>
</tr>
Expand Down
38 changes: 33 additions & 5 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,13 +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();
$('#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');
} else {
$('#fileSystemUrl').removeAttr('title').removeAttr('pattern')
$('#fileSystemUrl').removeAttr('title').removeAttr('pattern');
$("label[for='fileSystemAuthTypePubKey']").show();
$('#fileSystemAuthTypePasswordSpan').text(sysNetfileSysDetAuthPasswd);
$("label[for='fileSystemUrl']").text(sysNetFileSysDetUrl);
}
}

Expand All @@ -313,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 All @@ -324,4 +352,4 @@ define(function() {
$(document).on('submit', '#fileSystemDetailsForm', saveFileSystem);
});

});
});
Loading