add nodecenterws config

This commit is contained in:
CaiHQ 2022-03-30 11:17:08 +08:00
parent a1a52ffc32
commit 897f59c2eb
2 changed files with 30 additions and 5 deletions

View File

@ -1084,6 +1084,21 @@
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<div class='input-group mb-3'>
<div class="input-group-prepend">
<span class="input-group-text"
id="inputGroup-sizing-default">加入网络WS</span>
</div>
<input type='text' class='form-control'
id='nodeCenterWSInput'>
<div class='input-group-append'>
<button class='btn btn-outline-secondary' type='button'
id='changeNodeCenterWS' onclick='changeNodeCenterWS()'>修改
</button>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<div class="input-group mb-3">
<div class="input-group-prepend">

View File

@ -10,11 +10,12 @@ function loadNodeConfig(event) {
function onLoadNodeConfig(data) {
global.config = data.data;
showNodeConfig(data);
if (!global.centerportalws) {
let port = global.config.nodeCenter.replace(/.*:/g, "");
const len = global.config.nodeCenter.length - port.length;
port = port - 1;
let url = global.config.nodeCenter.substring(0, len) + port + "/NodeCenterWS";
let url = global.config.nodeCenterWS;
if (window.location.origin.startsWith("https")){
url = url.replace("ws://","wss://");
}
if (window.location.origin === "https://contract.internetapi.cn") {
url = "wss://cluster.contract.internetapi.cn/NodeCenterWS";
}
@ -28,7 +29,7 @@ function onLoadNodeConfig(data) {
}));
}, centerportalWSHandler);
}
showNodeConfig(data);
}
function showNodeConfig(data) {
@ -44,6 +45,7 @@ function showNodeConfig(data) {
$("#expireTime").html(global.config.expireTime);
$("#yjsInput")[0].value = global.config.yjsPath;
nodeCenterInputEl[0].value = global.config.nodeCenter;
$("#nodeCenterWSInput")[0].value = global.config.nodeCenterWS;
if (global.config.clusterConnected && global.config.clusterConnected === "true") {
nodeCenterInputEl.css("color", "green");
} else {
@ -167,6 +169,14 @@ function changeNodeCenter(event) {
}));
}
function changeNodeCenterWS(event) {
console.log("changeNodeCenterWS");
global.wssocket.send(JSON.stringify({
action: 'changeNodeCenterWS',
data: $("#nodeCenterWSInput")[0].value
}));
}
function onChangeNodeCenter(event) {
// console.log("onChangeNodeCenter", data);
myToast("成功", "修改NodeCenter成功")