diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py
index ac705226f..8a068421c 100755
--- a/plugins/mongodb/index.py
+++ b/plugins/mongodb/index.py
@@ -1052,6 +1052,14 @@ def replInit():
return mw.returnJson(True, '设置副本成功!')
+def replClose():
+ d = getConfigData()
+ if 'replSetName' in d['replication']:
+ del d['replication']['replSetName']
+ setConfig(d)
+ restart()
+ return mw.returnJson(True, '关闭副本同步成功!')
+
def testData():
'''
cd /www/server/mdserver-web && source bin/activate && python3 /www/server/mdserver-web/plugins/mongodb/index.py test_data
@@ -1254,6 +1262,8 @@ if __name__ == "__main__":
print(delReplNode())
elif func == 'repl_init':
print(replInit())
+ elif func == 'repl_close':
+ print(replClose())
elif func == 'run_log':
print(runLog())
elif func == 'test':
diff --git a/plugins/mongodb/js/mongodb.js b/plugins/mongodb/js/mongodb.js
index 8bb351ecf..711017bb6 100644
--- a/plugins/mongodb/js/mongodb.js
+++ b/plugins/mongodb/js/mongodb.js
@@ -159,9 +159,10 @@ function mongoReplStatus() {
| me | ' + rdata.me + ' | 本机 |
';
}
+ // console.log(rdata);
var repl_on = 'btn-danger';
var repl_on_title = '未开启';
- if (rdata['repl_name'] != ''){
+ if ('repl_name' in rdata && rdata['repl_name'] != ''){
repl_on = '';
repl_on_title = '已开启';
}
@@ -322,7 +323,7 @@ function mongoReplCfg(){
area: ['580px', '380px'],
closeBtn: 1,
shadeClose: false,
- btn: ["初始化","取消","添加节点","设置同步副本"],
+ btn: ["初始化","取消","添加节点","设置同步副本","关闭副本同步"],
content: '\
\
\
@@ -350,9 +351,9 @@ function mongoReplCfg(){
mgPost('repl_init', '', '', function(data){
var rdata = $.parseJSON(data.data);
showMsg(rdata.msg,function(){
- if (rdata['status']){
- mongoReplStatus();
- }
+
+ mongoReplStatus();
+
},{icon: rdata.status ? 1 : 2});
});
return false;
@@ -364,6 +365,17 @@ function mongoReplCfg(){
btn4:function(){
mongoReplCfgReplSetName();
return false;
+ },
+ btn5:function(){
+ mgPost('repl_close', '', '', function(data){
+ var rdata = $.parseJSON(data.data);
+ showMsg(rdata.msg,function(){
+ if (rdata['status']){
+ mongoReplStatus();
+ }
+ },{icon: rdata.status ? 1 : 2});
+ });
+ return false;
}
});
}