Skip to content
Snippets Groups Projects
Commit a52be768 authored by Mark M. Florida's avatar Mark M. Florida
Browse files

XNAT-4431: better checking for port conflicts when creating/editing DICOM SCP receivers

parent 1ae54699
No related branches found
No related tags found
No related merge requests found
...@@ -105,6 +105,7 @@ var XNAT = getObject(XNAT || {}); ...@@ -105,6 +105,7 @@ var XNAT = getObject(XNAT || {});
dicomScpManager.dialog = function(item, isNew){ dicomScpManager.dialog = function(item, isNew){
var tmpl = $('#dicom-scp-editor-template'); var tmpl = $('#dicom-scp-editor-template');
var doWhat = !item ? 'New' : 'Edit'; var doWhat = !item ? 'New' : 'Edit';
var oldPort = item && item.port ? item.port : null;
isNew = firstDefined(isNew, doWhat === 'New'); isNew = firstDefined(isNew, doWhat === 'New');
console.log(isNew); console.log(isNew);
item = item || {}; item = item || {};
...@@ -148,17 +149,18 @@ var XNAT = getObject(XNAT || {}); ...@@ -148,17 +149,18 @@ var XNAT = getObject(XNAT || {});
} }
}); });
var portNumber = $port.val(); var newPort = $port.val();
console.log(portNumber); console.log(newPort);
if (isNew){ // only check for port conflicts if we're changing the port
dicomScpManager.usedPorts.forEach(function(port){ if (newPort+'' !== oldPort+''){
if (port+'' === portNumber+''){ dicomScpManager.usedPorts.forEach(function(usedPort){
if (usedPort+'' === newPort+''){
errors++; errors++;
errorMsg += '<li>Port <b>' + portNumber + '</b> is already in use. Please use another port number.</li>'; errorMsg += '<li>Port <b>' + newPort + '</b> is already in use. Please use another port number.</li>';
$port.addClass('invalid'); $port.addClass('invalid');
return false; return false;
} }
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment