feat: init; from commit c3adcb2e6bc94b46f4f34c03bc62abcce6c7e1a0 of BDContract
This commit is contained in:
27
js/codeManage/contractAuthManage.js
Normal file
27
js/codeManage/contractAuthManage.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var updateResultDisplay = function(obj){
|
||||
obj_label = document.getElementById("result");
|
||||
var jsonData = JSON.stringify(obj);// 转成JSON格式
|
||||
// var result = $.parseJSON(jsonData);// 转成JSON对象
|
||||
obj_label.innerHTML = jsonData;
|
||||
};
|
||||
|
||||
var updateResultDisplayStr = function(str){
|
||||
obj_label = document.getElementById("result");
|
||||
obj_label.innerHTML = str;
|
||||
};
|
||||
|
||||
var alertNoPermission = function(message, title) {
|
||||
if ($("#nopermissionSpan").length>0){
|
||||
console.log(message+" status:"+$("#dialog")[0].getAttribute("class"));
|
||||
$("#nopermissionSpan").append("<br/>"+message);
|
||||
} else {
|
||||
var body = "<div class='row'><div class='col-sm-12'><span id='nopermissionSpan'>";
|
||||
body +=message;
|
||||
body += "</span></div></div>";
|
||||
$("#dialogBodyDiv").html(body);
|
||||
showDialog("提示",function(){
|
||||
$("#dialogBodyDiv").html("");
|
||||
});
|
||||
}
|
||||
return;
|
||||
};
|
||||
70
js/codeManage/fileManage.js
Normal file
70
js/codeManage/fileManage.js
Normal file
@@ -0,0 +1,70 @@
|
||||
var onDeleteFile = function(obj) {
|
||||
myToast("删除文件", obj.data);
|
||||
if (obj.data == "success") {
|
||||
listFiles();
|
||||
listMemoryFiles();
|
||||
}
|
||||
};
|
||||
|
||||
var deleteYpk = function(){
|
||||
if(global.ypkName == undefined || global.ypkName == "请选择ypk文件"){
|
||||
myToast("提示","请先选择要删除的文件!");
|
||||
return;
|
||||
}
|
||||
showDelete(global.ypkName);
|
||||
};
|
||||
|
||||
var showDelete = function(projectName) {
|
||||
var body = "<div class='input-group mb-3'>";
|
||||
body += " <span class='input-group-text' >请确认是否删除:" + projectName
|
||||
+ "?</span>";
|
||||
body += " </div>";
|
||||
$("#dialogBodyDiv").html(body);
|
||||
showDialog("删除ypk文件", function() {
|
||||
global.projectName = projectName;
|
||||
deleteFile();
|
||||
});
|
||||
};
|
||||
|
||||
var deleteFile = function() {
|
||||
var pingObj = {};
|
||||
pingObj.file = global.projectName;
|
||||
pingObj.action = "deleteFile";
|
||||
pingObj.isCompiled = true;
|
||||
pingObj.isPrivate = global.ypkIsPrivate;
|
||||
global.filewssocket.send(JSON.stringify(pingObj));
|
||||
};
|
||||
|
||||
var showDialog = function(title, cb) {
|
||||
$("#dialogTitleH5").html(title);
|
||||
$("#dialogConfimBtn").off("click").on("click", cb);
|
||||
$("#dialog").modal("show");
|
||||
};
|
||||
|
||||
var deleteMemoryFile = function(){
|
||||
if(global.memoryFile == undefined || global.memoryFile == "选择时间"){
|
||||
myToast("提示","请先选择要删除的文件!");
|
||||
return;
|
||||
}
|
||||
showDeleteMemoryFile(global.memoryFile);
|
||||
};
|
||||
|
||||
var showDeleteMemoryFile = function(projectName) {
|
||||
var body = "<div class='input-group mb-3'>";
|
||||
body += " <span class='input-group-text' >请确认是否删除:" + projectName
|
||||
+ "?</span>";
|
||||
body += " </div>";
|
||||
$("#dialogBodyDiv").html(body);
|
||||
showDialog("删除镜像文件", function() {
|
||||
deleteFileMemoryFile();
|
||||
});
|
||||
};
|
||||
|
||||
var deleteFileMemoryFile = function() {
|
||||
var pingObj = {};
|
||||
pingObj.file = global.memoryFile;
|
||||
pingObj.contractName = global.instanceName;
|
||||
pingObj.action = "deleteMemoryFile";
|
||||
global.wssocket.send(JSON.stringify(pingObj));
|
||||
};
|
||||
|
||||
331
js/codeManage/operManage.js
Normal file
331
js/codeManage/operManage.js
Normal file
@@ -0,0 +1,331 @@
|
||||
var initUnitsocket = function() {
|
||||
if (global.config == undefined) {
|
||||
var param = {};
|
||||
param.action = "loadNodeConfig";
|
||||
global.wssocket.send(JSON.stringify(param));
|
||||
setTimeout(initUnitsocket, 1000);
|
||||
return;
|
||||
}
|
||||
var port = global.config.nodeCenter.replace(/.*:/g, "");
|
||||
var len = global.config.nodeCenter.length - port.length;
|
||||
port = port - 1;
|
||||
var url = global.config.nodeCenter.substring(0, len) + port
|
||||
+ "/NodeCenterWS";
|
||||
if (window.location.origin == "https://contract.internetapi.cn") {
|
||||
url = "wss://cluster.contract.internetapi.cn/NodeCenterWS";
|
||||
}
|
||||
if (window.location.origin == "http://contract.internetapi.cn") {
|
||||
url = "ws://cluster.contract.internetapi.cn/NodeCenterWS";
|
||||
}
|
||||
console.log("connect :" + url);
|
||||
global.unitsocket = createWssocket(url, function() {
|
||||
getUnitSession();
|
||||
}, WSUnitHandler);
|
||||
}
|
||||
|
||||
// TODO we should get the address from config!
|
||||
var getUnitWsUrl = function(host) {
|
||||
var prefix = "ws://";
|
||||
if (document.location.href.startsWith("https"))
|
||||
prefix = "wss://";
|
||||
var path = "NodeCenterWS";
|
||||
var port = ":18001";
|
||||
if (host == "contract.internetapi.cn") {
|
||||
host = "cluster.contract.internetapi.cn";
|
||||
port = "";
|
||||
}
|
||||
return prefix + host + port + "/" + path;
|
||||
};
|
||||
|
||||
var getUnitSession = function() {
|
||||
if(global.centerportalws == undefined || global.centerportalws == null || global.centerportalws.send == undefined || global.centerportalws.send == null){
|
||||
|
||||
}
|
||||
global.centerportalws.send("{\"action\":\"getSessionID\"}");
|
||||
};
|
||||
|
||||
var onSessionID = function(data) {
|
||||
global.session = data.session;
|
||||
|
||||
var loginParam = {};
|
||||
loginParam.pubKey = global.sm2Key.publicKey;
|
||||
loginParam.signature = sm2.doSignature(global.session,
|
||||
global.sm2Key.privateKey,{hash:true,der:true});
|
||||
loginParam.action = "login";
|
||||
global.centerportalws.send(JSON.stringify(loginParam));
|
||||
|
||||
};
|
||||
|
||||
var onLogin = function(data) {
|
||||
// console.log(data);
|
||||
};
|
||||
|
||||
var distributeContract = function() {
|
||||
var place = $("#selectUnits")[0].value;
|
||||
if (place == "选择节点集群") {
|
||||
myToast("提示","请选择集群分发合约!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(global.ypkName == undefined || global.ypkName == "请选择ypk文件"){
|
||||
myToast("提示","请选择文件!");
|
||||
return;
|
||||
}
|
||||
|
||||
var unitsID = place.split(":")[1];
|
||||
var nodeIDs = ""; //公钥
|
||||
for ( var i in global.units[unitsID]) {
|
||||
if(global.units[unitsID][i].nodeName == global.config.nodeName)
|
||||
continue;
|
||||
nodeIDs += global.units[unitsID][i].pubKey + ",";
|
||||
}
|
||||
|
||||
if(nodeIDs == ""){
|
||||
myToast("提示","集群中无需要分发的节点!");
|
||||
return;
|
||||
}
|
||||
|
||||
var request = {};
|
||||
request.action = "distributeContract";
|
||||
request.nodeIDs = nodeIDs;
|
||||
request.projectName = global.ypkName;
|
||||
request.isPrivate = global.ypkIsPrivate;
|
||||
//request.sponsorName = global.config.nodeName;
|
||||
request.signature = sm2.doSignature("DistributeContract|"
|
||||
+ request.projectName + "|" + global.sm2Key.publicKey,
|
||||
global.sm2Key.privateKey,{hash:true,der:true}); // 合约的签名
|
||||
console.log(request);
|
||||
//global.centerportalws.send(JSON.stringify(request));
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onDistributeContract = function(obj) {
|
||||
updateResultDisplay(obj);
|
||||
};
|
||||
|
||||
var onDistributeFinish = function(obj) {
|
||||
customAlert("合约分发完成!");
|
||||
};
|
||||
|
||||
// 将所选周期转化为毫秒
|
||||
var switchPeriod = function(per) {
|
||||
switch (per) {
|
||||
case '/12hours自动保存':
|
||||
return (12 * 3600 * 1000) + "";
|
||||
case '/1day自动保存':
|
||||
return (24 * 3600 * 1000) + "";
|
||||
case '/2days自动保存':
|
||||
return (48 * 3600 * 1000) + "";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
// 本地启动
|
||||
var startContractAtSlave = function() {
|
||||
//this is for fixed contract,not for the unit contract
|
||||
var period = $("#selectDumpPeriod")[0].value;
|
||||
if (period == "选择状态保存模式") {
|
||||
myToast("提示","请选择状态保存模式!");
|
||||
return;
|
||||
}
|
||||
var dumpPeriod = switchPeriod(period);
|
||||
var project = global.ypkName;
|
||||
|
||||
$("#result")[0].innerHTML="正在启动,请稍候";
|
||||
var request = {};
|
||||
request.action = "startContractByYPK";
|
||||
request.dumpPeriod = dumpPeriod;
|
||||
request.isPrivate = global.ypkIsPrivate;
|
||||
request.owner = global.sm2Key.publicKey;
|
||||
request.requestID = new Date().getTime() + "";
|
||||
// request.contractid = $("#tabdiv")[0].value;
|
||||
// request.script = global.scriptEditor.getValue();
|
||||
request.path = "/" + project;
|
||||
localStorage.setItem("persisStatus", JSON.stringify(request));
|
||||
{
|
||||
request.signature = sm2.doSignature("Fixed|" + request.path + "|"
|
||||
+ global.sm2Key.publicKey, global.sm2Key.privateKey,{hash:true,der:true});
|
||||
request.script = "empty";
|
||||
}
|
||||
console.log(request);
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onStartContract = function(obj) {
|
||||
listContractProcess();
|
||||
updateResultDisplay(obj);
|
||||
};
|
||||
|
||||
// 集群启动合约
|
||||
var startContractUnits = function(place) {
|
||||
// ZYX
|
||||
var unitsID = $("#selectUnits")[0].value.split(":")[1];
|
||||
if(unitsID == undefined || unitsID == "选择节点集群"){
|
||||
myToast("提示","请选择节点集群!");
|
||||
return;
|
||||
}
|
||||
|
||||
var peersID = "";
|
||||
for ( var i in global.units[unitsID]) {
|
||||
peersID += global.units[unitsID][i].pubKey + ",";
|
||||
}
|
||||
|
||||
var request = {};
|
||||
|
||||
request.action = "startContractMultiPoint";
|
||||
request.peersID = peersID;
|
||||
request.type = $("#sequence")[0].value;
|
||||
console.log(request.type);
|
||||
if (request.type==0){
|
||||
myToast("提示","请选择集群合约模式!");
|
||||
return;
|
||||
}
|
||||
request.projectName = global.ypkName;
|
||||
if (request.projectName==undefined || request.projectName == "请选择ypk文件"){
|
||||
myToast("提示","请选择合约!");
|
||||
return;
|
||||
}
|
||||
request.isPrivate = global.ypkIsPrivate;
|
||||
request.sponsorPeerID = global.peerID; //peerID of the node
|
||||
console.log(request);
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onStartTrustfulContract = function(obj) {
|
||||
console.log(obj);
|
||||
$("#dialogBodyDiv").html("");
|
||||
customAlert("集群启动合约已完成!请等待各节点的结果(<span id='countDown'>20</span>)");
|
||||
setTimeout(decreaseCountDown,1000);
|
||||
};
|
||||
var decreaseCountDown = function(){
|
||||
if ($("#countDown").length!=1){
|
||||
return;
|
||||
}
|
||||
var val = $("#countDown").html();
|
||||
val/=1;
|
||||
if (val>0) val--;
|
||||
$("#countDown").html(val);
|
||||
setTimeout(decreaseCountDown,1000);
|
||||
}
|
||||
var onStartContractTrustfullyResult = function(obj){
|
||||
var data = JSON.parse(obj.data);
|
||||
$("#countDown").remove();
|
||||
$("#customAlertSpan").html("集群启动合约已完成!总共用时("+obj.executionTime+"ms)");
|
||||
if ($("#startP2PResultTable").length>0){
|
||||
}else{
|
||||
var html = "<table id='startP2PResultTable' style='width:100%' ><thead><tr><td>PubKey</td><td>结果</td></tr></thead><tbody>";
|
||||
html+="</tbody></table>";
|
||||
$("#customAlertSpan").parent().append(html);
|
||||
$("#startP2PResultTable").DataTable(
|
||||
{
|
||||
"language" : dtLang,
|
||||
"rowCallback" : function(row, data, displayNum, displayIndex,
|
||||
dataIndex) {
|
||||
|
||||
},
|
||||
"headerCallback" : function(thead, data, start, end, display) {
|
||||
$(thead).css("background", primaryColor);
|
||||
$(thead).css("color", "white");
|
||||
$(thead).children().css("background", primaryColor);
|
||||
$(thead).children().css("color", "white");
|
||||
},
|
||||
scrollCollapse : false,
|
||||
paging : true,
|
||||
pageLength : 5,
|
||||
order : [ [ 1, 'desc' ] ],
|
||||
"columnDefs" : []
|
||||
});
|
||||
}
|
||||
var p = $("#startP2PResultTable").DataTable();
|
||||
p.row.add([data.pubKey.substr(0,6),data.result]);
|
||||
p.row().draw();
|
||||
};
|
||||
|
||||
var customAlert = function(msg){
|
||||
if ($("#customAlertSpan").length>0){
|
||||
$("#customAlertSpan").append("<br/>"+msg);
|
||||
} else {
|
||||
var body = "<div class='row'><div class='col-sm-12'><span id='customAlertSpan'>";
|
||||
body +=msg;
|
||||
body += "</span></div></div>";
|
||||
$("#dialogBodyDiv").html(body);
|
||||
showDialog("提示",function(){
|
||||
$("#dialogBodyDiv").html("");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var startContractConfig = function() {
|
||||
if (global.ypkIsPrivate) {
|
||||
myToast("提示","私有合约不支持随机执行");
|
||||
return
|
||||
}
|
||||
var project = global.ypkName;
|
||||
if(project==undefined) {
|
||||
myToast("提示","未选择合约");
|
||||
return
|
||||
}
|
||||
var num = document.getElementById("selectUnitNum").value;
|
||||
var re = /^[0-9]+.?[0-9]*/;//判断字符串是否为数字//判断正整数/[1−9]+[0−9]∗]∗/
|
||||
if (!re.test(num)) {
|
||||
myToast("提示","请选择合理节点数量");
|
||||
return
|
||||
}
|
||||
var nameParts = $("#selectUnits")[0].value.split("_");
|
||||
var unitsID = nameParts[1];
|
||||
var request = {};
|
||||
var peers;
|
||||
var network = $("#network")[0].value;
|
||||
if (unitsID == undefined) {
|
||||
console.log("unitsID " + unitsID);
|
||||
} else if (network == 1) {
|
||||
peers = global.p2pNodes;
|
||||
} else {
|
||||
peers = global.units[unitsID];
|
||||
}
|
||||
if (peers.length < num) {
|
||||
myToast("失败","节点数量 > 集群节点数量");
|
||||
return
|
||||
}
|
||||
var peersID = "";
|
||||
for ( var i in peers) {
|
||||
if (peers[i].peerID) {
|
||||
peersID += peers[i].peerID +" ";
|
||||
} else {
|
||||
peersID += peers[i] + " ";
|
||||
}
|
||||
}
|
||||
console.log("peers ", peersID)
|
||||
request.action = "startContractConfig";
|
||||
request.type = network;
|
||||
request.peersID = peersID;
|
||||
request.num = num;
|
||||
request.path = "/" + project;
|
||||
request.contractName = project;
|
||||
request.signature = sm2.doSignature("Trusted|" + request.path + "|"
|
||||
+ global.sm2Key.publicKey, global.sm2Key.privateKey); // 合约的签名
|
||||
request.sequencing = $("#sequence")[0].value;
|
||||
request.response = $("#response")[0].value;
|
||||
console.log("startContractConfig",request)
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
}
|
||||
|
||||
var onStartContractConfig = function(obj) {
|
||||
updateResultDisplay(obj);
|
||||
listContractProcess();
|
||||
};
|
||||
|
||||
var onHashResult = function(obj) {
|
||||
$("#hashDisplayDiv").html("溯源指纹:"+obj.data);
|
||||
};
|
||||
|
||||
var startTestADSP = function(obj){
|
||||
var request = {};
|
||||
request.action = "startTestADSP";
|
||||
global.centerportalws.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onStartTestADSP = function(obj){
|
||||
myToast("提示","开始测试ADSP!");
|
||||
};
|
||||
85
js/codeManage/projectManage.js
Normal file
85
js/codeManage/projectManage.js
Normal file
@@ -0,0 +1,85 @@
|
||||
var initcodeManage = function(){
|
||||
console.log("initcodeManage");
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
loadNodeConfig(); //调用节点管理,获得可选择集群
|
||||
|
||||
setTimeout(function() {
|
||||
getUnitSession();
|
||||
|
||||
}, 2000);
|
||||
|
||||
$("#ypkIsPrivate")[0].value = "公共目录";
|
||||
changeYpkPath();
|
||||
|
||||
getP2PNodes();
|
||||
};
|
||||
var getP2PNodes = function() {
|
||||
console.log("getP2PNodes")
|
||||
global.wssocket.send("{\"action\":\"getP2PNodes\"}");
|
||||
}
|
||||
|
||||
var onGetP2PNodes = function(obj) {
|
||||
global.p2pNodes = obj.peers;
|
||||
console.log("onGetP2PNodes function", obj);
|
||||
var json = {};
|
||||
json.type = "P2P";
|
||||
json.value = obj.peers;
|
||||
json.key = "_P2PUnit";
|
||||
console.log("onGetP2PNodes json", json);
|
||||
addNodeUnit(json);
|
||||
}
|
||||
|
||||
var changeYpkPath = function () {
|
||||
var isPublic =$("#ypkIsPrivate")[0].innerHTML;
|
||||
if(isPublic == "公共目录"){
|
||||
$("#ypkIsPrivate")[0].innerHTML = "私有目录";
|
||||
global.ypkIsPrivate = true;
|
||||
listFiles();
|
||||
}else{
|
||||
$("#ypkIsPrivate")[0].innerHTML = "公共目录";
|
||||
global.ypkIsPrivate = false;
|
||||
listFiles();
|
||||
}
|
||||
};
|
||||
|
||||
var listFiles = function() {
|
||||
var isPublic =$("#ypkIsPrivate")[0].innerHTML;
|
||||
console.log(isPublic);
|
||||
if(isPublic == "公共目录"){
|
||||
global.wssocket.send("{\"action\":\"listCompiledFiles\",\"isPrivate\":false}");
|
||||
}else{
|
||||
global.wssocket.send("{\"action\":\"listCompiledFiles\",\"isPrivate\":true}");
|
||||
}
|
||||
};
|
||||
|
||||
var updateGlobalProject = function() {
|
||||
setTimeout(updateGlobalProjectInternal, 100);
|
||||
};
|
||||
|
||||
var updateGlobalProjectInternal = function() {
|
||||
var isPublic = $("#publicDir-tab").hasClass("active");
|
||||
console.log("updateGlobalProject, isPublic:" + isPublic);
|
||||
if (isPublic)
|
||||
global.projects = global.publicProjects;
|
||||
else
|
||||
global.projects = global.privateProjects;
|
||||
mainVue.projects = global.projects;
|
||||
};
|
||||
|
||||
var changeYpkName = function(obj) {
|
||||
global.ypkName = obj;
|
||||
console.log("global.ypkName = " + global.ypkName);
|
||||
};
|
||||
|
||||
var onListCompiledFiles = function(obj) {
|
||||
global.filewssocket = global.wssocket;
|
||||
var data = JSON.parse(obj.data);
|
||||
console.log(data);
|
||||
var html = "<option selected>请选择ypk文件</option>";
|
||||
for(var i = 0;i < data.length;i++){
|
||||
html += ("<option selected>" + data[i] + "</option>");
|
||||
changeYpkName(data[i]);
|
||||
}
|
||||
$("#selectYpkFile").html(html);
|
||||
};
|
||||
96
js/codeManage/recoverFrame.js
Normal file
96
js/codeManage/recoverFrame.js
Normal file
@@ -0,0 +1,96 @@
|
||||
var dumpContract = function() {
|
||||
if (global.contractInstance == undefined){
|
||||
myToast("失败","请选择合约实例");
|
||||
return;
|
||||
}
|
||||
|
||||
var request = {};
|
||||
request.action = "dumpContract";
|
||||
request.contractID = global.instanceName;
|
||||
console.log(request);
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onDumpContract = function(obj) {
|
||||
obj_label = document.getElementById("recoverResult");
|
||||
var show = "保存合约状态" + obj.data + ",状态文件大小" + obj.size + ",保存用时" + obj.time;
|
||||
obj_label.value = show;
|
||||
listMemoryFiles();
|
||||
};
|
||||
|
||||
var listMemoryFiles = function(){
|
||||
console.log("listMemoryFiles");
|
||||
if(global.instanceName == undefined || global.instanceName == ""){
|
||||
return;
|
||||
}
|
||||
var request = {};
|
||||
request.action = "listMemoryFiles";
|
||||
request.contractID = global.instanceName;
|
||||
console.log(request);
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onListMemoryFiles = function(obj){
|
||||
var files = obj.data;
|
||||
console.log(files);
|
||||
if(files == undefined || files.length == 0){
|
||||
var htm = "<option selected>选择时间</option>";
|
||||
$("#selectMemeryFiles").html(htm);
|
||||
return;
|
||||
}
|
||||
|
||||
var htm = "";
|
||||
if(files.length > 0){
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
console.log(files[i]);
|
||||
htm += "<option selected>" + files[i] + "</option>";
|
||||
}
|
||||
}
|
||||
htm += "<option selected>选择时间</option>";
|
||||
console.log(htm);
|
||||
|
||||
$("#selectMemeryFiles").html(htm);
|
||||
changeMemeryFiles($("#selectMemeryFiles")[0].value);
|
||||
};
|
||||
|
||||
var transferTo = function(){
|
||||
var memoryFile = $("#selectMemeryFiles")[0].value;
|
||||
if(memoryFile == "选择时间"){
|
||||
myToast("提示","请选择时间!");
|
||||
return;
|
||||
}
|
||||
|
||||
var request = {};
|
||||
request.action = "loadMemory";
|
||||
request.contractName = global.instanceName;
|
||||
request.memoryFile = memoryFile;
|
||||
console.log(request);
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onTransferTo = function(obj){
|
||||
obj_label = document.getElementById("recoverResult");
|
||||
var show = "合约状态迁移" + obj.data + ",状态文件大小" + obj.size + ",迁移用时" + obj.time;
|
||||
obj_label.value = show;
|
||||
listMemoryFiles();
|
||||
};
|
||||
|
||||
|
||||
|
||||
var getSyncType = function(contractName){
|
||||
var request = {};
|
||||
request.action = "getSyncType";
|
||||
request.contractName = contractName;
|
||||
console.log(request);
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
|
||||
var onGetSyncType = function(obj){
|
||||
if(obj.data == "Memory" || obj.data == "Trace" || obj.data == "Trans"){
|
||||
global.contractSynType = obj.data;
|
||||
obj_label = document.getElementById("syncResult");
|
||||
var show = "合约 " + global.instanceName + " 的同步机制策略为 " + obj.data;
|
||||
obj_label.value = show;
|
||||
}else
|
||||
global.contractSynType = "failed";
|
||||
};
|
||||
151
js/codeManage/selectManage.js
Normal file
151
js/codeManage/selectManage.js
Normal file
@@ -0,0 +1,151 @@
|
||||
var listContractProcess = function() {
|
||||
console.log("listContractProcess : ");
|
||||
var request = {};
|
||||
request.action = "listContractProcess";
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
|
||||
};
|
||||
|
||||
var onListContractProcess = function(obj) {
|
||||
var userManTab = $("#v-pills-contractInstance-tab")[0];
|
||||
var isActive = (userManTab.getAttribute("aria-selected") == "true");
|
||||
if (isActive) {
|
||||
onListContractProcess1(obj);
|
||||
} else {
|
||||
onListContractProcess2(obj);
|
||||
}
|
||||
};
|
||||
|
||||
var changeContractProcess = function(obj) {
|
||||
global.contractProcess = obj; // 代码管理菜单选中的合约
|
||||
console.log("oooooooooooo" + global.contractProcess);
|
||||
//showPermissionList(global.contractProcess);
|
||||
};
|
||||
|
||||
var onListContractProcess2 = function(obj) {
|
||||
var data = JSON.parse(obj.data);
|
||||
|
||||
global.contracts = data;
|
||||
// $("#contractProcess").editableSelect('clear');
|
||||
// $("#tabdiv").html("");
|
||||
|
||||
global.contractName2ID = {};
|
||||
//global.permissionNameMap = {};
|
||||
var name = "";
|
||||
var htm = "<option selected>选择合约进程</option>";
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
// htm += "<option value='" + 0 + "'>" + data[i].name + "</option>";
|
||||
htm += "<option selected>" + data[i].name + "</option>";
|
||||
global.contractName2ID[data[i].name] = data[i].id;
|
||||
//global.permissionNameMap[data[i].name] = data[i].contractPermission;
|
||||
console.log(htm);
|
||||
name = data[i].name;
|
||||
}
|
||||
//showPermissionList(name);
|
||||
console.log(htm);
|
||||
$("#contractProcess").html(htm);
|
||||
|
||||
/*
|
||||
* $("#contractProcess").editableSelect({ effects: 'slide',
|
||||
* //可选参数default、fade filter: true //false 不过滤,否则选中后其它选项消失 });
|
||||
*/
|
||||
|
||||
/*
|
||||
* if(data.length > 0){ for (var i = 0; i < data.length; i++) {
|
||||
* console.log(i); $("#contractProcess").editableSelect('add',
|
||||
* data[i].name); global.contractName2ID[data[i].name] = data[i].id; //
|
||||
* $("#tabdiv").append( // $("<option></option>").attr("value",
|
||||
* data[i].id).text( // data[i].id)); } } if (data.length > 0)
|
||||
* $("#contractProcess").editableSelect()[0].value = data[0].name;
|
||||
*/
|
||||
};
|
||||
|
||||
var addTcpNodeUnits = function(data) {
|
||||
if (data.length > 0) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var unitID = data[i].key;
|
||||
var nodes = JSON.parse(data[i].value);
|
||||
var json = {};
|
||||
json.type = "TCP";
|
||||
json.key = unitID;
|
||||
json.value = nodes;
|
||||
addNodeUnit(json);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var listSelectUnits = function(data) {
|
||||
console.log(data);
|
||||
global.units = {};
|
||||
var htm = "";
|
||||
if (data.length > 0) {
|
||||
// data的key是创建人公钥_时间戳,value是nodes的ID
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var unitID = data[i].key;
|
||||
var nodes = JSON.parse(data[i].value);
|
||||
var at_ = data[i].key.indexOf("_");
|
||||
console.log(nodes);
|
||||
htm += "<option>集群:" + unitID.substring(at_ + 1)
|
||||
+ "</option>";
|
||||
global.units[unitID.substring(at_ + 1)] = nodes;
|
||||
}
|
||||
}
|
||||
htm += "<option selected>选择节点集群</option>";
|
||||
htm += "<option>无</option>";
|
||||
console.log(htm);
|
||||
|
||||
$("#selectUnits").html(htm);
|
||||
}
|
||||
var onCancelAuth = function(obj) {
|
||||
myToast("取消权限", obj.data);
|
||||
if (obj.data == "success") {
|
||||
}
|
||||
};
|
||||
|
||||
var setPermission = function(data) {
|
||||
var request = {};
|
||||
request.resetContractProcess = data.name;
|
||||
console.log(request.resetContractName);
|
||||
request.closePer = data.permission;
|
||||
request.oldPer = data.oldPermission;
|
||||
request.isOpen = data.isOpen;
|
||||
request.action = "setPermission";
|
||||
global.wssocket.send(JSON.stringify(request));
|
||||
};
|
||||
var onSetPermission = function(obj) {
|
||||
console.log(obj);
|
||||
|
||||
var html = "<div class='input-group mb-2'>";
|
||||
|
||||
html += "<div class='input-group-prepend'>";
|
||||
html += "<span class='input-group-text' id='inputGroup-sizing-default'>";
|
||||
html += "状态保存策略:" + "</span></div>";
|
||||
html += "<div class='input-group-append'>";
|
||||
html += "<select id='selectDumpPeriod2' class='custom-select' style='appearance: none; -webkit-appearance: none;'>";
|
||||
|
||||
if(period == "43200000"){
|
||||
html += "<option selected>/1day自动保存</option>";
|
||||
html += "<option selected>/2days自动保存</option> ";
|
||||
html += "<option selected>不保存</option>";
|
||||
html += "<option selected>/12hours自动保存</option>";
|
||||
}else if(period == "86400000"){
|
||||
html += "<option selected>/2days自动保存</option> ";
|
||||
html += "<option selected>不保存</option>";
|
||||
html += "<option selected>/12hours自动保存</option>";
|
||||
html += "<option selected>/1day自动保存</option>";
|
||||
}else if(period == "172800000"){
|
||||
html += "<option selected>不保存</option>";
|
||||
html += "<option selected>/12hours自动保存</option>";
|
||||
html += "<option selected>/1day自动保存</option>";
|
||||
html += "<option selected>/2days自动保存</option> ";
|
||||
}else{
|
||||
html += "<option selected>/12hours自动保存</option>";
|
||||
html += "<option selected>/1day自动保存</option>";
|
||||
html += "<option selected>/2days自动保存</option> ";
|
||||
html += "<option selected>不保存</option>";
|
||||
}
|
||||
};
|
||||
|
||||
var onListLeakContractProcess = function(obj){
|
||||
drawCPTable(obj);
|
||||
}
|
||||
Reference in New Issue
Block a user