feat: support createParam

This commit is contained in:
CaiHQ 2022-04-21 10:14:00 +08:00
parent 897f59c2eb
commit b0f4c4225b
4 changed files with 59 additions and 15 deletions

View File

@ -230,15 +230,22 @@
onchange="changeYpkName(this.value)">
<option selected>请选择ypk文件</option>
</select>
<input class="form-control" id="createParam"
placeholder="填写启动参数" class="modal_input"/>
<div class="input-group-text">
<input type="checkbox" id="autoConvertStr"
aria-label="Checkbox for convertParam"
data-toggle="tooltip"
checked
title="" data-original-title="自动将参数转为JSON对象"/>
</div>
<select id="selectDumpPeriod" class="custom-select"
style="appearance: none">
<option selected>不保存</option>
<option selected>/12hours自动保存</option>
<option selected>/1day自动保存</option>
<option selected>/2days自动保存</option>
<option selected>选择状态保存模式</option>
<option>/12hours自动保存</option>
<option>/1day自动保存</option>
<option>/2days自动保存</option>
<option>选择状态保存模式</option>
</select>
<div class="input-group-append">
<button onclick="deleteYpk()"
@ -1094,7 +1101,8 @@
id='nodeCenterWSInput'>
<div class='input-group-append'>
<button class='btn btn-outline-secondary' type='button'
id='changeNodeCenterWS' onclick='changeNodeCenterWS()'>修改
id='changeNodeCenterWS' onclick='changeNodeCenterWS()'>
修改
</button>
</div>
</div>
@ -1356,6 +1364,7 @@
</script>
</body>

View File

@ -102,8 +102,6 @@ function drawConInfoTable(table) {
<th>状态</th>
<th>端口</th>
<th>类型</th>
<th>通讯</th>
<th>共识</th>
<!--<th>返回方式</th>-->
<th>次数</th>
<th>流量</th>
@ -125,19 +123,20 @@ ${table[i].name}
<td>${table[i]['contractStatus']}</td>
<td>${table[i].port || '-'}</td>
<td>${table[i].type}</td>
<td>${table[i]['networkType'] ? "P2P" : "TCP"}</td>
<td>${table[i]['consensusType'] ? CONSENSUS_TABLE[table[i]['consensusType']] : '无'}</td>
<!--<td>${table[i]['networkType'] ? "P2P" : "TCP"}</td>-->
<!--<td>${table[i]['consensusType'] ? CONSENSUS_TABLE[table[i]['consensusType']] : '无'}</td>-->
<!--<td>${table[i].responseType ? RESPONSE_TYPE_TABLE[table[i].responseType] : '-'}</td>-->
<td>${table[i].times}</td>
<td>${table[i]['traffic'] || '-'}</td>
<td>${table[i].storage || '-'}</td>
<td style='padding:2px 12px 2px 12px'>
<button onclick="stopContractByID('${table[i].id}')" class="btn btn-secondary">停止</button>
<button onclick="restartContractByID('${table[i].id}')" class="btn btn-secondary">重启</button>
</td>
</tr>`
}
html += tableTail;
html = "<h5 class='card-title'>DO实例列表</h5>" + html;
html = "<h5 class='card-title'>DO实例列表</h5>" + "<button onclick='pruneKilledContract()' class='btn btn-secondary' style='float:right'>清除已停合约</button>"+html;
ciTabDiv.html(html);
$("#ciTabDivTab").DataTable(
@ -184,6 +183,29 @@ function stopContractByID(contractID) {
});
}
function pruneKilledContract() {
$("#dialogBodyDiv").html("是否清除已停合约" );
showDialog("请确认", function () {
global.wssocket.send(JSON.stringify({
action: 'pruneKilledContract',
requestID: new Date().getTime().toString()
}));
setTimeout(listContractProcess,1000);
});
}
function restartContractByID(contractID) {
$("#dialogBodyDiv").html("是否重启合约ContractID" + contractID);
showDialog("请确认", function () {
global.wssocket.send(JSON.stringify({
action: 'restartContractProcess',
requestID: new Date().getTime().toString(),
id: contractID
}));
});
}
function drawContractInstanceStatusPie(table) {
const ciStatusPieDiv = $("#ciStatusPieDiv")
if (ciStatusPieDiv.css("height") === "0px") {

View File

@ -353,12 +353,12 @@ function initResponseAndOutputArea() {
function onExecuteResult(obj) {
const executeResultTitleEl = $("#executeResultTitle");
const data = obj;
var sytleTail = "未知格式";
var styleTail = "未知格式";
if (data.result==undefined) {
styleTail = "Undefined";
data.result = "";
} else if (data.result instanceof Object) {
sytleTail = "JSON格式";
styleTail = "JSON格式";
data.result =JSON.stringify(data.result);
} else if (typeof data.result == 'string') {
styleTail = "字符串格式";

View File

@ -131,10 +131,23 @@ var startContractAtSlave = function() {
}
var dumpPeriod = switchPeriod(period);
var project = global.ypkName;
$("#result")[0].innerHTML="正在启动,请稍候";
var request = {};
request.action = "startContractByYPK";
if (createParam !='') {
request.createParam = createParam.value;
$("#createParam").css("color","");
if (autoConvertStr.value=='on') {
try{
request.createParam = JSON.parse(request.createParam);
$("#createParam").css("color","");
}catch(e){
console.log(e);
$("#createParam").css("color","red");
}
}else{
}
}
request.dumpPeriod = dumpPeriod;
request.isPrivate = global.ypkIsPrivate;
request.owner = global.sm2Key.publicKey;