Revision e0c27075
Added by Jim Pingle almost 15 years ago
usr/local/www/javascript/load_balancer_pool_edit/pool.js | ||
---|---|---|
110 | 110 |
} |
111 | 111 |
} |
112 | 112 |
|
113 |
function checkPoolControls() { |
|
114 |
var active = document.iform.serversSelect; |
|
115 |
var inactive = document.iform.serversDisabledSelect; |
|
116 |
if ($("mode").value == "failover") { |
|
117 |
if ($("serversSelect").length > 0) { |
|
118 |
$("moveToEnabled").disabled=1; |
|
119 |
} else { |
|
120 |
$("moveToEnabled").disabled=0; |
|
121 |
} |
|
122 |
} else { |
|
123 |
$("moveToEnabled").disabled=0; |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
function enforceFailover() { |
|
128 |
if ($("mode").value != "failover") { |
|
129 |
return; |
|
130 |
} |
|
131 |
var active = document.iform.serversSelect; |
|
132 |
var inactive = document.iform.serversDisabledSelect; |
|
133 |
var count = 0; |
|
134 |
var moveText = new Array(); |
|
135 |
var moveVals = new Array(); |
|
136 |
var i; |
|
137 |
if (active.length > 1) { |
|
138 |
// Move all but one entry to the disabled list |
|
139 |
for (i=active.length-1; i>0; i--) { |
|
140 |
moveText[count] = active.options[i].text; |
|
141 |
moveVals[count] = active.options[i].value; |
|
142 |
deleteOption(active, i); |
|
143 |
count++; |
|
144 |
} |
|
145 |
for (i=count-1; i>=0; i--) { |
|
146 |
addOption(inactive, moveText[i], moveVals[i]); |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
113 | 151 |
// functions up() and down() modified from http://www.babailiica.com/js/sorter/ |
114 | 152 |
|
115 | 153 |
function up(obj) { |
usr/local/www/load_balancer_pool.php | ||
---|---|---|
129 | 129 |
$t->edit_uri('load_balancer_pool_edit.php'); |
130 | 130 |
$t->my_uri('load_balancer_pool.php'); |
131 | 131 |
$t->add_column(gettext('Name'),'name',10); |
132 |
$t->add_column(gettext('Mode'),'mode',10); |
|
132 | 133 |
$t->add_column(gettext('Servers'),'servers',15); |
133 | 134 |
$t->add_column(gettext('Port'),'port',10); |
134 |
$t->add_column(gettext('Monitor'),'monitor',15);
|
|
135 |
$t->add_column(gettext('Description'),'desc',30);
|
|
135 |
$t->add_column(gettext('Monitor'),'monitor',10);
|
|
136 |
$t->add_column(gettext('Description'),'desc',25);
|
|
136 | 137 |
$t->add_button('edit'); |
137 | 138 |
$t->add_button('dup'); |
138 | 139 |
$t->add_button('del'); |
usr/local/www/load_balancer_pool_edit.php | ||
---|---|---|
53 | 53 |
|
54 | 54 |
if (isset($id) && $a_pool[$id]) { |
55 | 55 |
$pconfig['name'] = $a_pool[$id]['name']; |
56 |
$pconfig['mode'] = $a_pool[$id]['mode']; |
|
56 | 57 |
$pconfig['desc'] = $a_pool[$id]['desc']; |
57 | 58 |
$pconfig['port'] = $a_pool[$id]['port']; |
58 | 59 |
$pconfig['servers'] = &$a_pool[$id]['servers']; |
... | ... | |
70 | 71 |
$pconfig = $_POST; |
71 | 72 |
|
72 | 73 |
/* input validation */ |
73 |
$reqdfields = explode(" ", "name port monitor servers"); |
|
74 |
$reqdfieldsn = array(gettext("Name"),gettext("Port"),gettext("Monitor"),gettext("Server List")); |
|
74 |
$reqdfields = explode(" ", "name mode port monitor servers");
|
|
75 |
$reqdfieldsn = array(gettext("Name"),gettext("Mode"),gettext("Port"),gettext("Monitor"),gettext("Server List"));
|
|
75 | 76 |
|
76 | 77 |
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); |
77 | 78 |
|
... | ... | |
110 | 111 |
$changedesc .= sprintf(gettext(" modified '%s' pool:"), $poolent['name']); |
111 | 112 |
|
112 | 113 |
update_if_changed("name", $poolent['name'], $_POST['name']); |
114 |
update_if_changed("mode", $poolent['mode'], $_POST['mode']); |
|
113 | 115 |
update_if_changed("description", $poolent['desc'], $_POST['desc']); |
114 | 116 |
update_if_changed("port", $poolent['port'], $_POST['port']); |
115 | 117 |
update_if_changed("servers", $poolent['servers'], $_POST['servers']); |
... | ... | |
170 | 172 |
<input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"{$pconfig['name']}\"";?> size="16" maxlength="16"> |
171 | 173 |
</td> |
172 | 174 |
</tr> |
175 |
<tr align="left"> |
|
176 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Mode"); ?></td> |
|
177 |
<td width="78%" class="vtable" colspan="2"> |
|
178 |
<select id="mode" name="mode" onChange="enforceFailover(); checkPoolControls();"> |
|
179 |
<option value="loadbalance" <?if(!isset($pconfig['mode']) || ($pconfig['mode'] == "loadbalance")) echo "value=\"{$pconfig['name']}\"";?>>Load Balance</option> |
|
180 |
<option value="failover" <?if($pconfig['mode'] == "failover") echo "value=\"{$pconfig['name']}\"";?>>Manual Failover</option> |
|
181 |
</select> |
|
182 |
</td> |
|
183 |
</tr> |
|
173 | 184 |
<tr align="left"> |
174 | 185 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td> |
175 | 186 |
<td width="78%" class="vtable" colspan="2"> |
... | ... | |
249 | 260 |
</td> |
250 | 261 |
|
251 | 262 |
<td valign="middle"> |
252 |
<input class="formbtn" type="button" name="moveToEnabled" value=">" onclick="moveOptions(document.iform.serversDisabledSelect, document.iform.serversSelect);" /><br/>
|
|
253 |
<input class="formbtn" type="button" name="moveToDisabled" value="<" onclick="moveOptions(document.iform.serversSelect, document.iform.serversDisabledSelect);" />
|
|
263 |
<input class="formbtn" type="button" id="moveToEnabled" name="moveToEnabled" value=">" onclick="moveOptions(document.iform.serversDisabledSelect, document.iform.serversSelect); checkPoolControls();" /><br/>
|
|
264 |
<input class="formbtn" type="button" id="moveToDisabled" name="moveToDisabled" value="<" onclick="moveOptions(document.iform.serversSelect, document.iform.serversDisabledSelect); checkPoolControls();" />
|
|
254 | 265 |
</td> |
255 | 266 |
|
256 | 267 |
<td> |
Also available in: Unified diff
Add the ability to select a mode for LB pool members, load balance (default) or manual failover. If manual failover is selected, only allow one server to be chosen as active.