support remote debug

This commit is contained in:
CaiHQ 2022-09-02 21:26:21 +08:00
parent 6f6be77dfe
commit 19d0c53304
4 changed files with 72 additions and 17 deletions

View File

@ -239,14 +239,20 @@
checked checked
title="" data-original-title="自动将参数转为JSON对象"/> title="" data-original-title="自动将参数转为JSON对象"/>
</div> </div>
<input class="form-control input-group-small"
id="remoteDebugPort"
placeholder="远程调试端口" class="modal_input"/>
<select id="selectDumpPeriod" class="custom-select" <select id="selectDumpPeriod" class="custom-select"
style="appearance: none"> style="appearance: none">
<option selected>不保存</option> <option selected>不保存</option>
<option>/12hours自动保存</option> <option>/12hours</option>
<option>/1day自动保存</option> <option>/1day</option>
<option>/2days自动保存</option> <option>/2days</option>
<option>选择状态保存模式</option> <option>状态保存模式</option>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button onclick="deleteYpk()" <button onclick="deleteYpk()"
type="button" title="删除该合约ypk文件" data-toggle="tooltip" type="button" title="删除该合约ypk文件" data-toggle="tooltip"
@ -257,9 +263,15 @@
</button> </button>
</div> </div>
<div class="input-group-append"> <div class="input-group-append">
<button type="button" class="btn btn-outline-primary"
title="使用该ypk单点调试启动" data-toggle="tooltip"
onclick="startContractAtSlave(true)">
<img alt="Brand" src="./images/onlineide/debug.png"
class="buttonimg">
</button>
<button type="button" class="btn btn-outline-primary" <button type="button" class="btn btn-outline-primary"
title="使用该ypk单点启动合约" data-toggle="tooltip" title="使用该ypk单点启动合约" data-toggle="tooltip"
onclick="startContractAtSlave()"> onclick="startContractAtSlave(false)">
<img alt="Brand" src="./images/onlineide/start.png" <img alt="Brand" src="./images/onlineide/start.png"
class="buttonimg"> class="buttonimg">
</button> </button>
@ -1366,6 +1378,9 @@
</script> </script>
</body> </body>

View File

@ -35,11 +35,6 @@
<!--script src="./js/echartsTheme.js"></script --> <!--script src="./js/echartsTheme.js"></script -->
<!-- script src="./js/echarts-gl.min.js"></script --> <!-- script src="./js/echarts-gl.min.js"></script -->
<script src="./js/sm2.js"></script> <script src="./js/sm2.js"></script>
<script src="./js/sm3.js"></script>
<script src="./js/sm4.js"></script>
<script src="./js/sm/index.js"></script>
<script src="./js/d3.v5.min.js"></script> <script src="./js/d3.v5.min.js"></script>
<!-- script src="./js/dagre-d3.min.js"></script --> <!-- script src="./js/dagre-d3.min.js"></script -->
<script src="./js/tipsy/jquery.tipsy.min.js"></script> <script src="./js/tipsy/jquery.tipsy.min.js"></script>
@ -390,12 +385,35 @@
</div> </div>
<div class="input-group mb-1"> <div class="input-group mb-1">
<div class="btn-group btn-block" role="group"> <div class="btn-group btn-block" role="group">
<input class="form-control input-group-small"
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>
</div>
</div>
<div class="input-group mb-1">
<div class="btn-group btn-block" role="group">
<input class="form-control input-group-small"
id="remoteDebugPort"
placeholder="调试端口" class="modal_input"/>
<button class="btn btn-outline-primary" <button class="btn btn-outline-primary"
onclick="startContractAsDebug()" type="button" id="button-debug" onclick="startContractAsDebug(true)" type="button" id="button-debug"
title="调试" data-toggle="tooltip"> title="调试启动" data-toggle="tooltip">
<img alt="Brand" src="./images/onlineide/debug.png" <img alt="Brand" src="./images/onlineide/debug.png"
class="buttonimg"> class="buttonimg">
</button> </button>
<button class="btn btn-outline-primary"
onclick="startContractAsDebug(false)" type="button" id="button-start"
title="启动" data-toggle="tooltip">
<img alt="Brand" src="./images/onlineide/start.png"
class="buttonimg">
</button>
</div> </div>
</div> </div>
<div class="input-group mt-1 mb-3"> <div class="input-group mt-1 mb-3">

View File

@ -120,9 +120,8 @@ var switchPeriod = function(per) {
return ""; return "";
} }
}; };
// 本地启动 // 本地启动
var startContractAtSlave = function() { var startContractAtSlave = function(isDebug) {
//this is for fixed contract,not for the unit contract //this is for fixed contract,not for the unit contract
var period = $("#selectDumpPeriod")[0].value; var period = $("#selectDumpPeriod")[0].value;
if (period == "选择状态保存模式") { if (period == "选择状态保存模式") {
@ -150,6 +149,10 @@ var startContractAtSlave = function() {
}else{ }else{
} }
} }
if (remoteDebugPort.value !='') {
request.remoteDebugPort = remoteDebugPort.value;
}
request.isDebug = isDebug;
request.dumpPeriod = dumpPeriod; request.dumpPeriod = dumpPeriod;
request.isPrivate = global.ypkIsPrivate; request.isPrivate = global.ypkIsPrivate;
request.owner = global.sm2Key.publicKey; request.owner = global.sm2Key.publicKey;

View File

@ -43,7 +43,7 @@ function startContract() {
global.wssocket.send(JSON.stringify(request)); global.wssocket.send(JSON.stringify(request));
} }
function startContractAsDebug() { function startContractAsDebug(isDebug) {
const key = pubkeyDialogVue.sm2KeyList[pubkeyDialogVue.selectedSM2Key]; const key = pubkeyDialogVue.sm2KeyList[pubkeyDialogVue.selectedSM2Key];
const sm2Key = JSON.parse(key.sm2Key); const sm2Key = JSON.parse(key.sm2Key);
const projectId = $("#selectedProject")[0].value; const projectId = $("#selectedProject")[0].value;
@ -51,9 +51,28 @@ function startContractAsDebug() {
startResult.innerText = "正在以调试模式启动合约:" + project; startResult.innerText = "正在以调试模式启动合约:" + project;
const request = {}; const request = {};
request.action = "startContractAsDebug"; request.action = "startContract";
request.isPrivate = $("#privateprojecttab").hasClass("active"); request.isPrivate = $("#privateprojecttab").hasClass("active");
if (createParam.value !='') {
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");
alert("Create Param not JSON Format");
return;
}
}else{
}
}
request.isDebug = isDebug;
if (remoteDebugPort.value !='') {
request.remoteDebugPort = remoteDebugPort.value;
}
request.owner = sm2Key.publicKey; request.owner = sm2Key.publicKey;
request.requestID = new Date().getTime() + ""; request.requestID = new Date().getTime() + "";
// request.contractid = $("#tabdiv")[0].value; // request.contractid = $("#tabdiv")[0].value;