From 1f26b2ccb36b2a065bd251c5aeeb7cfedd2e4c52 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Mon, 24 Jul 2017 11:56:09 +0000 Subject: [PATCH] SSDM-5409 : SFTP Links and enable SFTP in our default ELN installations SVN: 38572 --- .../eln-lims/html/js/config/Profile.js | 10 +- .../as/webapps/eln-lims/html/js/util/Util.js | 93 +++++++++++++------ .../DataSetForm/widgets/DatasetViewerModel.js | 2 +- .../reporting-plugins/eln-lims-api/script.py | 42 ++++----- 4 files changed, 90 insertions(+), 57 deletions(-) diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js index fd748a4ebcb..76a78831952 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js @@ -154,7 +154,10 @@ $.extend(DefaultProfile.prototype, { } this.directLinkEnabled = true; - this.directFileServer = null; //To be set during initialization using info retrieved from the DSS configuration by the reporting plugin + //To be set during initialization using info retrieved from the DSS configuration by the reporting plugin + this.cifsFileServer = null; + this.sftpFileServer = null; + this.copyPastePlainText = false; this.hideCodes = true; this.hideTypes = { @@ -749,8 +752,9 @@ $.extend(DefaultProfile.prototype, { this.initDirectLinkURL = function(callback) { var _this = this; this.serverFacade.getDirectLinkURL(function(error, result) { - if(!error && result.data.protocol) { - _this.directFileServer = result.data; + if(!error && (result.data.cifs || result.data.sftp)) { + _this.cifsFileServer = result.data.cifs; + _this.sftpFileServer = result.data.sftp; } callback(); }); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js index 98ed8d37458..03a29609bd0 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js @@ -250,6 +250,28 @@ var Util = new function() { }); } + this.getDirectLinkWindows = function(protocol, config, path) { + var hostName = window.location.hostname; + var suffix = config.UNCsuffix; + if(!suffix) { + suffix = ""; + } + var port = config.port; + + return "\\\\" + hostName + "\\" + (new String(suffix + path).replace(new RegExp("/", 'g'),"\\")); + } + + this.getDirectLinkUnix = function(protocol, config, path) { + var hostName = window.location.hostname; + var suffix = config.UNCsuffix; + if(!suffix) { + suffix = ""; + } + var port = config.port; + + return protocol + "://" + hostName + ":" + port + "/" + suffix + path; + } + this.showDirectLink = function(path) { var css = { 'text-align' : 'left', @@ -260,42 +282,59 @@ var Util = new function() { 'overflow' : 'hidden' }; - var hostName = window.location.hostname; - var protocol = profile.directFileServer.protocol; - var suffix = profile.directFileServer.UNCsuffix; - if(!suffix) { - suffix = ""; - } - var port = profile.directFileServer.port; - - directLinkUnix = protocol + "://" + hostName + ":" + port + "/" + suffix + path; - directLinkWin = "\\\\" + hostName + "\\" + (new String(suffix + path).replace(new RegExp("/", 'g'),"\\")); - var $close = $("<div>", { style : "float:right;" }) - .append($("<a>", { class : 'btn btn-default' }).append($("<span>", { class : 'glyphicon glyphicon-remove' }))).click(function() { - Util.unblockUI(); - }); - var isWindows = window.navigator.userAgent.toLowerCase().indexOf("windows") > -1; - var $window = null; + var cifsLink = null; + var sftpLink = null; + if(isWindows) { - var $readOnlyInput = $("<input>", { class : "form-control", id : "windowsLink", readonly : "readonly", type : "text", value : directLinkWin, onClick : "this.setSelectionRange(0, this.value.length)" }); - - $window = $("<div>").append($close).append($("<h1>").append("Direct Link")) - .append("Please use this link to access the folder though the network, copy it on the explorer address bar: ") - .append($("<br>")) - .append($readOnlyInput); + if(profile.cifsFileServer) { + cifsLink = this.getDirectLinkWindows("cifs", profile.cifsFileServer, path); + } + if(profile.sftpFileServer) { + sftpLink = this.getDirectLinkUnix("sftp", profile.sftpFileServer, path); + } } else { - $window = $("<div>").append($close).append($("<h1>").append("Direct Link")) - .append("Please use this link to access the folder though the network, directly clicking on it will open it with the default application: ") - .append($("<br>")) - .append($("<b>Link: </b>")) - .append($("<a>", { "href" : directLinkUnix, "target" : "_blank"}).append(directLinkUnix)); + if(profile.cifsFileServer) { + cifsLink = this.getDirectLinkUnix("cifs", profile.cifsFileServer, path); + } + if(profile.sftpFileServer) { + sftpLink = this.getDirectLinkUnix("sftp", profile.sftpFileServer, path); + } } + var $close = $("<div>", { style : "float:right;" }) + .append($("<a>", { class : 'btn btn-default' }).append($("<span>", { class : 'glyphicon glyphicon-remove' }))).click(function() { + Util.unblockUI(); + }); + + var $window = $("<div>").append($close).append($("<h1>").append("Direct Links")); + $window.append("To access the folder though the network you have the next options:").append($("<br>")); $window.css("margin-bottom", "10px"); $window.css("margin-left", "10px"); $window.css("margin-right", "10px"); + if(isWindows) { + if(profile.cifsFileServer) { + var $readOnlyInput = $("<input>", { class : "form-control", id : "windowsLink", readonly : "readonly", type : "text", value : cifsLink, onClick : "this.setSelectionRange(0, this.value.length)" }); + $window.append("<b>CIFS Link: </b>").append($readOnlyInput).append("NOTE: The CIFS link can be copied directly on windows explorer address bar."); + $window.append($("<br>")).append($("<br>")); + } + if(profile.sftpFileServer) { + $window.append("<b>SFTP Link: </b>").append($("<br>")).append($("<a>", { "href" : sftpLink, "target" : "_blank"}).append(sftpLink)).append($("<br>")); + $window.append("NOTE: The SFTP link can be opened with your favourite SFTP application, we recomend ").append($("<a>", { "href" : "https://cyberduck.io/", "target" : "_blank"}).append("Cyberduck")).append("."); + } + } else { + + if(profile.cifsFileServer) { + $window.append($("<b>CIFS Link: </b>")).append($("<a>", { "href" : cifsLink, "target" : "_blank"}).append(cifsLink)).append($("<br>")); + } + if(profile.sftpFileServer) { + $window.append($("<b>SFTP Link: </b>")).append($("<a>", { "href" : sftpLink, "target" : "_blank"}).append(sftpLink)).append($("<br>")); + } + + $window.append("NOTE: Directly clicking on the links will open them with the default application. ").append("For SFTP we recomend ").append($("<a>", { "href" : "https://cyberduck.io/", "target" : "_blank"}).append("Cyberduck")).append("."); + } + Util.blockUI($window, css); } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/DatasetViewerModel.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/DatasetViewerModel.js index 790f9389767..8e38069d5ec 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/DatasetViewerModel.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/DatasetViewerModel.js @@ -74,7 +74,7 @@ function DataSetViewerModel(containerId, profile, entity, serverFacade, datastor this.getDirectDirectoryLink = function(datasetCode, pathInDataSet) { var directLinkComponent = null; - if(profile.directLinkEnabled && profile.directFileServer) { + if(profile.directLinkEnabled && (profile.cifsFileServer || profile.sftpFileServer)) { var path = null; if(this.isExperiment()) { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py index af4acd2c9e5..c724c84920c 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py @@ -77,43 +77,33 @@ def getConfigParameterAsString(propertyKey): return property; def getDirectLinkURL(): - #CIFS cifsServerEnable = getConfigParameterAsString("cifs.server.enable"); cifsServerPort = getConfigParameterAsString("cifs.server.smb-port"); #SFTP + sftpServerEnable = getConfigParameterAsString("ftp.server.enable"); sftpPort = getConfigParameterAsString("ftp.server.sftp-port"); - #FTPS - ftpServerEnable = getConfigParameterAsString("ftp.server.enable"); - ftpServerUseSsl = getConfigParameterAsString("ftp.server.use-ssl"); - useSsl = getConfigParameterAsString("use-ssl"); - ftpPortLegacy = getConfigParameterAsString("ftp.server.port"); - ftpPort = getConfigParameterAsString("ftp.server.ftp-port"); - - protocol = None; - port = None; - UNCsuffix = None; + cifsConfig = None; if (cifsServerEnable == "true") and (cifsServerPort is not None): - protocol = "cifs" - port = cifsServerPort; - UNCsuffix = "STORE/"; - elif (sftpPort is not None): - protocol = "sftp"; - port = sftpPort; - elif (ftpServerEnable == "true") and ((ftpPort is not None) or (ftpPortLegacy is not None)) and (ftpServerUseSsl == "true" or useSsl == "true"): - protocol = "ftps"; - if ftpPort is not None: - port = ftpPort; - elif ftpPortLegacy is not None: - port = ftpPortLegacy; + cifsConfig = { + "port" : cifsServerPort, + "UNCsuffix" : "STORE/" + } + + sftpConfig = None; + if (sftpServerEnable == "true") and (sftpPort is not None): + sftpConfig = { + "port" : sftpPort, + "UNCsuffix" : "" + } return getJsonForData({ - "protocol" : protocol, - "port" : port, - "UNCsuffix" : UNCsuffix + "cifs" : cifsConfig, + "sftp" : sftpConfig }); + def isSampleTypeAvailable(sampleTypes, sampleTypeCode): for sampleType in sampleTypes: -- GitLab