blob: d33caf23b5bfc4e29880f3db371d223ff29cd0d2 [file] [log] [blame]
##Licensed to the Apache Software Foundation (ASF) under one or more
##contributor license agreements. See the NOTICE file distributed with
##this work for additional information regarding copyright ownership.
##The ASF licenses this file to You under the Apache License, Version 2.0
##(the "License"); you may not use this file except in compliance with
##the License. You may obtain a copy of the License at
##
##http://www.apache.org/licenses/LICENSE-2.0
##
##Unless required by applicable law or agreed to in writing, software
##distributed under the License is distributed on an "AS IS" BASIS,
##WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##See the License for the specific language governing permissions and
##limitations under the License.
#set($layout = "/templates/governance/layout/default.vm")
<div class="ico_btn">
<a href="../loadbalances"><img src="$rootContextPath.getURI("images/ico_back.png")" width="12" height="12"/><span
class="ico_font">#springMessageText("back", "back")</span></a>
</div>
<br/>
<form id="df" action="../loadbalances/create" method="POST" onsubmit="return check()">
<table cellpadding="0" cellspacing="0" class="info">
<tr>
<th style="width: 150px;">#springMessageText("service", "service")&nbsp;&nbsp;<font color='red'>*</font></th>
<td>#if($service)
<input type="hidden" id="service" name="service" value="$service"/>$service
#if($input)
<button onclick="window.location.href='../loadbalances/add'; return false;">#springMessageText(
"Edit","Edit")</button>
#end
#else
<input type="text" id="service" name="service" value="$!route.serviceName" style="ime-mode:disabled"
maxlength="200"/>
#if ($serviceList && $serviceList.size() > 0)
<select onchange="if (this.value != '') { byId('service').value = this.value; this.value = ''; }">
<option value="">#springMessageText("Choose", "Choose")</option>
#foreach ($s in $serviceList)
<option value="$s">$tool.getSimpleName($s)</option>
#end
</select>
#end
<button onclick="if(byId('service').value == '') { showAlert('#springMessageText("PleaseInput", "PleaseInput")#springMessageText(
"ServiceName", "ServiceName")', 'service'); } else if(!checkService(byId('service').value)) { showAlert('Service name can not contain , only last * is allowed', 'service'); } else { window.location.href='../services/' + byId('service').value+'/loadbalances/add?input=true'; } return false;">#springMessageText(
"getMethods","getMethods")</button>
<br>
<font color='blue'>#springMessageText("MultiServiceTip", "MultiServiceTip")</font>
#end
</td>
</tr>
<tr>
<th style="width: 150px;">#springMessageText("methodName", "methodName")&nbsp;&nbsp;<font color='red'>*</font></th>
<td>
<input type="type" id="method" name="method" value="*" style="ime-mode:disabled" maxlength="200"/>
#if ($methods)
<select onchange="if (this.value != '') {byId('method').value = this.value; this.value = '';}">
<option value="">#springMessageText("Choose", "Choose")</option>
#foreach ($m in $methods)
<option value="$m">$m</option>
#end
</select>
#end
<font color="blue">&nbsp;&nbsp;“*”代表所有方法</font>
</td>
</tr>
<tr>
<th>#springMessageText("loadBalanceStrategy", "loadBalanceStrategy"):</th>
<td>
<input type="text" id="strategy" name="strategy" style="ime-mode:disabled" maxlength="200" value=""/>
<select id="lbstrategy" name="lbstrategy"
onchange="if (this.value != '') { byId('strategy').value = this.value; this.value = ''; }">>
<option value="">#springMessageText("Choose", "Choose")</option>
<option value="random">#springMessageText("random", "random")</option>
<option value="roundrobin">#springMessageText("roundrobin", "roundrobin")</option>
<option value="leastactive">#springMessageText("leastactive", "leastactive")</option>
</select>
</td>
</tr>
<tr>
<th>
<div class="btn"><a href="#" onclick="if(check()){document.getElementById('df').submit();}">#springMessageText(
"save","save")</a></div>
</th>
<td></td>
</tr>
</table>
</form>
<script language="javascript">
function checkService(service) {
//if(service.indexOf(',') != -1) return false;
var interfaceName = service;
var gi = service.indexOf('/');
if (gi != -1) interfaceName = interfaceName.substring(gi + 1);
var vi = interfaceName.indexOf(':');
if (vi != -1) interfaceName = interfaceName.substring(0, vi);
if (interfaceName.indexOf('*') != -1 && interfaceName.indexOf('*') != interfaceName.length - 1) {
return false;
}
return true;
}
function check() {
var method = byId('method').value.trim();
if (method == '') {
showAlert("#springMessageText("PleaseInput", "PleaseInput")#springMessageText("methodName", "methodName")", 'method');
return false;
}
var strategy = byId('strategy').value.trim();
if (strategy == '') {
showAlert("#springMessageText("PleaseInput", "PleaseInput")#springMessageText("loadBalanceStrategy", "loadBalanceStrategy")", 'strategy');
return false;
}
return true;
}
</script>