diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index 2950fa99e..250bd4cfe 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -1002,13 +1002,18 @@ def replSetName(): def replSetNode(): args = getArgs() - data = checkArgs(args, ['node']) + data = checkArgs(args, ['node','priority','arbiterOnly','votes','idx']) if not data[0]: return data[1] c = getReplConfigData() nodes = c['nodes'] add_node = args['node'].strip() + idx = int(args['idx']) + + + + priority = -1 if 'priority' in args: @@ -1028,6 +1033,18 @@ def replSetNode(): votes = args['votes'] votes = int(votes) + # 编辑状态 + if idx>-1: + for i in range(len(nodes)): + if i == idx: + nodes[i]['host'] = add_node + nodes[i]['priority'] = priority + nodes[i]['votes'] = votes + nodes[i]['arbiterOnly'] = arbiterOnly + c['nodes'] = nodes + setReplConfigData(c) + return mw.returnJson(True, '编辑成功!') + is_have = False for x in nodes: if x['host'] == add_node: @@ -1045,7 +1062,7 @@ def replSetNode(): nodes.append(t) c['nodes'] = nodes setReplConfigData(c) - return mw.returnJson(True, '设置成功!') + return mw.returnJson(True, '添加成功!') def delReplNode(): diff --git a/plugins/mongodb/js/mongodb.js b/plugins/mongodb/js/mongodb.js index 7575a2307..bfbcca450 100644 --- a/plugins/mongodb/js/mongodb.js +++ b/plugins/mongodb/js/mongodb.js @@ -252,7 +252,7 @@ function mongoReplCfgReplSetName(){ }); } -function mongoReplCfgNodes(host, priority, votes, arbiterOnly){ +function mongoReplCfgNodes(idx,host, priority, votes, arbiterOnly){ if (typeof(host) == 'undefined'){ host = '127.0.0.1:27017'; @@ -270,6 +270,11 @@ function mongoReplCfgNodes(host, priority, votes, arbiterOnly){ arbiterOnly = '1'; } + var title_name = '添加节点'; + if (idx>-1){ + title_name = '编辑节点'; + } + layer.open({ type: 1, area: '500px', @@ -278,7 +283,7 @@ function mongoReplCfgNodes(host, priority, votes, arbiterOnly){ shift: 5, shadeClose: true, btn:["提交","关闭"], - content: "