Author: jfthomps
Date: Thu Feb 5 21:00:14 2015
New Revision: 1657691
URL: http://svn.apache.org/r1657691
Log:
VCL-174 - NAT - support for sites that have small IP address ranges
updated code so that the drop down for selecting a NAT host when changing the
nat host setting for multiple computers gets dynamically updated as computers
are configured/unconfigured as NAT hosts
computer.php: modified extraResourceFilters: set an id for the 'Confirm NAT
Change' button
managementnode.php: (just removed unnecessary newlines)
utils.php: modified getNAThosts: added conditionals to not include deleted
computers and management nodes
computers.js:
-modified initPage: added line to disable newnathostbtn if there are no options
in newnathostid
-modified saveResourceCB: add option to netnathostid select when an added or
edited computer is enabled as a nat host and set newnathostbtn to be enabled;
if a computer is edited and removed as a nat host, remove the computer from the
options in newnathostid, if no options left, disable newnathostbtn
-modified confirmNATchange: if no options in newnathostid, return
Modified:
vcl/trunk/web/.ht-inc/computer.php
vcl/trunk/web/.ht-inc/managementnode.php
vcl/trunk/web/.ht-inc/utils.php
vcl/trunk/web/js/resources/computer.js
Modified: vcl/trunk/web/.ht-inc/computer.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/computer.php?rev=1657691&r1=1657690&r2=1657691&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/computer.php (original)
+++ vcl/trunk/web/.ht-inc/computer.php Thu Feb 5 21:00:14 2015
@@ -225,7 +225,7 @@ class Computer extends Resource {
$cdata = $this->basecdata;
$cont = addContinuationsEntry('AJcompNATchange', $cdata);
$h .= " <input type=\"hidden\" id=\"natchangecont\"
value=\"$cont\"><br>\n";
- $h .= dijitButton('', 'Confirm NAT Change',
'confirmNATchange();', 0);
+ $h .= dijitButton('newnathostbtn', 'Confirm NAT Change',
'confirmNATchange();', 0);
$h .= " </div>\n";
$h .= " </div>\n";
Modified: vcl/trunk/web/.ht-inc/managementnode.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/managementnode.php?rev=1657691&r1=1657690&r2=1657691&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/managementnode.php (original)
+++ vcl/trunk/web/.ht-inc/managementnode.php Thu Feb 5 21:00:14 2015
@@ -940,10 +940,6 @@ class ManagementNode extends Resource {
}
}
-
-
-
-
$nathosterror = 0;
# nathostenabled
if($return['nathostenabled'] != 0 && $return['nathostenabled']
!= 1) {
Modified: vcl/trunk/web/.ht-inc/utils.php
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1657691&r1=1657690&r2=1657691&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Thu Feb 5 21:00:14 2015
@@ -8704,7 +8704,9 @@ function getNAThosts($id=0, $sort=0) {
. "LEFT JOIN resource r ON (n.resourceid = r.id) "
. "LEFT JOIN resourcetype rt ON (r.resourcetypeid = rt.id) "
. "LEFT JOIN computer c ON (c.id = r.subid AND rt.name =
'computer') "
- . "LEFT JOIN managementnode m ON (m.id = r.subid AND rt.name =
'managementnode')";
+ . "LEFT JOIN managementnode m ON (m.id = r.subid AND rt.name =
'managementnode') "
+ . "WHERE (c.deleted IS NULL OR c.deleted = 0) AND "
+ . "(m.stateid IS NULL OR m.stateid != (SELECT id FROM
state WHERE name = 'deleted'))";
if($id)
$query .= " WHERE n.id = $id";
$qh = doQuery($query);
Modified: vcl/trunk/web/js/resources/computer.js
URL:
http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/computer.js?rev=1657691&r1=1657690&r2=1657691&view=diff
==============================================================================
--- vcl/trunk/web/js/resources/computer.js (original)
+++ vcl/trunk/web/js/resources/computer.js Thu Feb 5 21:00:14 2015
@@ -248,7 +248,7 @@ var resource = new Computer();
function initPage() {
if(dojo.byId('reloadpageurl'))
return;
- document.body.style.cursor = 'wait';
+ document.body.style.cursor = 'wait';
if(! ('resourcegrid' in window)) {
setTimeout(function() {
initPage();
@@ -277,6 +277,11 @@ function initPage() {
for(var i = 0; i <
dojo.byId('filtercompgroups').options.length; i++) {
dojo.byId('filtercompgroups').options[i].selected =
true;
}
+
+ // confirm new nathost button
+ if(dijit.byId('newnathostid').options.length == 0)
+ dijit.byId('newnathostbtn').set('disabled', true);
+
clearTimeout(filterdelay);
}
}
@@ -850,8 +855,11 @@ function saveResourceCB(data, ioArgs) {
if(typeof resourcegrid !== 'undefined') {
resourcegrid.store.newItem(data.items.data);
resourcegrid.sort();
- if(data.items.data.nathostenabled)
+ if(data.items.data.nathostenabled) {
dijit.byId('nathostid').addOption({label: data.items.data.hostname, value:
data.items.data.nathostenabledid});
+
dijit.byId('newnathostid').addOption({label: data.items.data.hostname, value:
data.items.data.nathostenabledid});
+
dijit.byId('newnathostbtn').set('disabled', false);
+ }
}
dojo.forEach(dijit.findWidgets(dojo.byId('groupdlgcontent')), function(w) {
w.destroyRecursive();
@@ -924,8 +932,11 @@ function saveResourceCB(data, ioArgs) {
resourcegrid.store.setValue(item,
'natpublicIPaddress', data.items.data.natpublicIPaddress);
resourcegrid.store.setValue(item,
'natinternalIPaddress', data.items.data.natinternalIPaddress);
if(data.items.data.nathostenabled) {
- if(washost == 0)
+ if(washost == 0) {
dijit.byId('nathostid').addOption({label: data.items.data.hostname, value:
data.items.data.nathostenabledid});
+
dijit.byId('newnathostid').addOption({label: data.items.data.hostname, value:
data.items.data.nathostenabledid});
+
dijit.byId('newnathostbtn').set('disabled', false);
+ }
}
else {
dijit.byId('nathostid').options.forEach(
@@ -934,6 +945,14 @@ function saveResourceCB(data, ioArgs) {
dijit.byId('nathostid').removeOption({value: node.value});
}
);
+
dijit.byId('newnathostid').options.forEach(
+ function(node, index,
nodelist) {
+ if(node.label
== data.items.data.hostname)
+
dijit.byId('newnathostid').removeOption({value: node.value});
+
if(dijit.byId('newnathostid').options.length == 0)
+
dijit.byId('newnathostbtn').set('disabled', true);
+ }
+ );
}
},
onComplete: function(items, result) {
@@ -1019,6 +1038,8 @@ function confirmPredictiveModuleChange()
}
function confirmNATchange() {
+ if(dijit.byId('newnathostid').options.length == 0)
+ return;
var data = {continuation: dojo.byId('natchangecont').value};
if(dijit.byId('newnatenabled').get('value') == 1) {
data['natenabled'] = 1;