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: "
\ + content: "\
\ 节点服务:\
\ @@ -316,6 +321,7 @@ function mongoReplCfgNodes(host, priority, votes, arbiterOnly){ data['priority'] = $('input[name=priority]').val(); data['votes'] = $('input[name=votes]').val(); data['arbiterOnly'] = $('select[name=arbiterOnly]').val(); + data['idx'] = idx; mgPost('repl_set_node', '',data, function(data){ var rdata = $.parseJSON(data.data); showMsg(rdata.msg,function(){ @@ -323,7 +329,7 @@ function mongoReplCfgNodes(host, priority, votes, arbiterOnly){ layer.close(index); mongoReplCfgInit(); } - },{icon: rdata.status ? 1 : 2},5000); + },{icon: rdata.status ? 1 : 2},rdata['status']?2000:10000); }); } }); @@ -356,7 +362,7 @@ function mongoReplCfgInit(){ } var op = '删除'; - op += ' | 编辑'; + op += ' | 编辑'; node += ''+t['host']+''+t['priority']+''+t['votes']+''+arbiterOnly+''+op+''; } $('#repl_node tbody').html(node); @@ -407,7 +413,7 @@ function mongoReplCfg(){ return false; }, btn3:function(){ - mongoReplCfgNodes(); + mongoReplCfgNodes(-1); return false; }, btn4:function(){