blob: 0398a3e86f20f3df914e5a196a70066c97820ad4 [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="../overrides"><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="../overrides/create" method="POST">
<table cellpadding="0" cellspacing="0" class="info" id="table1">
#if(! $service)
<tr>
<td style="width: 100px;"><b>#springMessageText("service", "service"):</b></td>
<td style="width: 300px;"><input id="service" type="text" name="service" class="setting_input"
style="width: 200px;"/>
<select onchange="fnSetService(this)">
<option value="">#springMessageText("Choose", "Choose")</option>
#foreach($s in $serviceList)
<option value="$s">$tool.getSimpleName($s)</option>
#end
</select>
</td>
</tr>
#else
<td><b>#springMessageText("service", "service"):</b></td>
<td
">$service<input id="service" type="hidden" name="service" class="setting_input" style="width: 200px;"
value="$service"/>
#end
<tr>
<td><b>#springMessageText("ConsumerApplication", "ConsumerApplication"):</b></td>
#if($app)
<td>$app</td>
#else
<td><input type="text" id="application" name="application" class="setting_input" style="width: 300px;"
value="" maxlength="200"/></td>
#end
</tr>
<tr>
<td><b>#springMessageText("overrideConsumerAddress", "overrideConsumerAddress"):</b></td>
<td><input type="text" id="address" name="address" class="setting_input" style="width: 300px;" value=""
maxlength="200"/> <font color="blue">#springMessageText("tipConsumerAddress", "tipConsumerAddress")</font></td>
</tr>
<tr>
<td><b>#springMessageText("status", "status"): <b></td>
<td>
<select name="enabled">
<option value="true">#springMessageText("enable", "enable")</option>
<option value="false" selected="selected">#springMessageText("disable", "disable")</option>
</select>
</td>
</tr>
</table>
<hr>
<b>#springMessageText("override.config", "override.config")</b>
<br>
<table cellpadding="0" cellspacing="0" class="info" id="paramTable">
<tr>
<td style="width: 150px;"><b>#springMessageText("parameter.key", "parameter.key"): </b><input name='overrideKey0' id='overrideKey0'
type='text' style='width: 100px;'/></td>
<td><b>#springMessageText("parameter.value", "parameter.value"): </b><input type="text" id="overrideValue0" name="overrideValue0"
class="setting_input" style="width: 300px;" value=""
maxlength="200"/> <font color="blue">#springMessageText(
"parameter.tip","parameter.tip")</font></td>
</tr>
</table>
<br>
<div class="btn">
<a href="#" onclick="paramTableAddRow(); return false;"><b>#springMessageText("add", "add")#springMessageText("parameter", "parameter")</b></a>
</div>
<br>
<br>
<hr>
<b>#springMessageText("override.mock", "override.mock")</b>
<br>
<table cellpadding="0" cellspacing="0" class="info" id="mockTable">
<tr>
<td style="width: 230px;"><b>#springMessageText("mock.all.method", "mock.all.method"):</b>
</th>
<td><select type="text" id="mockDefaultMethodForce" name="mockDefaultMethodForce">
<option value='fail'>#springMessageText("fail.mock", "fail.mock")</option>
<option value='force'>#springMessageText("force.mock", "force.mock")</option>
</select></td>
<td><input type="text" id="mockDefaultMethodJson" name="mockDefaultMethodJson" class="setting_input"
style="width: 300px;" value="" maxlength="200"/> <font color="blue">#springMessageText("mock.tip", "mock.tip")</font>
</td>
</tr>
</table>
<br/>
<div class="btn">
<a href="#" onclick="mockTableAddRow(); return false;"><b>#springMessageText("add", "add")#springMessageText("mock.method", "mock.method")</b></a>
</div>
<br/>
<hr>
<br/>
<div class="btn">
<a href="#" onclick="if(check()){byId('df').submit();}"><b>#springMessageText("save", "save")</b></a>
</div>
</form>
<script language="javascript">
function fnSetService(obj) {
if (obj.value != '') {
document.getElementById('service').value = obj.value;
}
}
function check() {
var service = byId('service').value.trim();
if (service == '') {
showAlert("#springMessageText("PleaseInput", "PleaseInput") #springMessageText("service", "service")", 'service');
return false;
}
var exp = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
var exp2 = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.\*$/;
var address = byId('address').value.trim();
if (address != "") {
if (!address.match(exp) && !address.match(exp2)) {
showAlert("#springMessageText("InvalidIp", "InvalidIp")", 'address');
return false;
}
}
return true;
}
function ismaxlength(obj) {
var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length > mlength)
showAlert("content maxlength is " + mlength + "!", 'docContent');
return false;
}
function imposeMaxLength(obj) {
var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
return (obj.value.length < mlength);
}
var paramTRLastIndex = 1; // 行号
function paramTableAddRow() {
var table = byId("paramTable");
var newTR = table.insertRow(table.rows.length);
newTR.id = "paramTable" + paramTRLastIndex;
var newNameTH = document.createElement('th');
var newNameTD = newTR.insertCell(0);
newNameTD.innerHTML = "<b>#springMessageText(
"parameter.key","parameter.key"): </b><input name='overrideKey" + paramTRLastIndex + "' id='overrideKey" + paramTRLastIndex + "' type='text' style='width: 100px;' />";
var newMockTD = newTR.insertCell(1);
newMockTD.innerHTML = "<b>#springMessageText(
"parameter.value","parameter.value"): </b><input type='text' id='overrideValue" + paramTRLastIndex + "' name='overrideValue" + paramTRLastIndex + "' class='setting_input' style='width: 300px;' value='' maxlength='200'/>"
+ "&nbsp;<a href='javascript:;' onclick=\"tableDeleteRow('paramTable', 'paramTable" + paramTRLastIndex + "'); return false;\">#springMessageText(
"delete","delete")</a>";
paramTRLastIndex++; //将行号推进下一行
}
var mockTRLastIndex = 1; // 行号
function mockTableAddRow() {
var table = byId("mockTable");
var newTR = table.insertRow(table.rows.length);
newTR.id = "mockTable" + mockTRLastIndex;
var newNameTH = document.createElement('th');
var newNameTD = newTR.insertCell(0);
newNameTD.innerHTML = "<b>#springMessageText(
"mock.method","mock.method"):</b><input name='mockMethodName" + mockTRLastIndex + "' id='mockMethodName" + mockTRLastIndex + "' type='text' style='width: 100px;' /><b>#springMessageText(
"mock.value","mock.value"):</b>";
var newNameTD = newTR.insertCell(1);
newNameTD.innerHTML = "<select name='mockMethodForce" + mockTRLastIndex + "' id='mockMethodForce" + mockTRLastIndex + "'><option value='fail'>#springMessageText(
"fail.mock","fail.mock")</option><option value='force'>#springMessageText("force.mock", "force.mock")</option></select>";
var newMockTD = newTR.insertCell(2);
newMockTD.innerHTML = "<input name='mockMethodJson" + mockTRLastIndex + "' id='mockMethodJson" + mockTRLastIndex + "' type='text' value='return empty' style='width: 300px;' />"
+ "&nbsp;<a href='javascript:;' onclick=\"tableDeleteRow('mockTable', 'mockTable" + mockTRLastIndex + "'); return false;\">#springMessageText(
"delete","delete")</a>";
mockTRLastIndex++; //将行号推进下一行
}
function tableDeleteRow(tableid, rowid) {
var table = byId(tableid);
var row = byId(rowid);
table.deleteRow(row.rowIndex);
}
</script>