Merge pull request #519 from imebeh/fix-portopen-test

fix port test
This commit is contained in:
栽培者 2021-02-02 20:46:40 +08:00 committed by GitHub
commit 4e0c781669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -698,34 +698,44 @@
// 测试端口 // 测试端口
thisDialog.find('#system-config-test-port').click(function () { thisDialog.find('#system-config-test-port').click(function () {
var button = $(this); var button = $(this);
button.linkbutton({ var newPort = parseInt(thisDialog.find('#peer-port').val());
text: system.lang.dialog['system-config'].testing,
disabled: true function buttonPortTestStatus(enabled) {
}); button.linkbutton({
text: system.lang.dialog['system-config'][enabled?'test-port':'testing'],
disabled: !enabled
});
}
function labelPortOpenStatus(opened) {
if (opened) {
thisDialog.find('#system-config-port-is-open-true').fadeInAndOut();
} else {
thisDialog.find('#system-config-port-is-open-false').fadeInAndOut();
}
}
buttonPortTestStatus(false);
// 如果端口有变更,则先保存 // 如果端口有变更,则先保存
if (parseInt(thisDialog.find('#peer-port').val()) != system.serverConfig['peer-port']) { if (newPort != system.serverConfig['peer-port']) {
transmission.exec({ transmission.exec({
method: 'session-set', method: 'session-set',
arguments: { arguments: {
'peer-port': true 'peer-port': newPort
} }
}, function (data) { }, function (data) {
if (data.result == 'success') { if (data.result == 'success') {
system.serverConfig['peer-port'] = newPort;
transmission.exec({ transmission.exec({
method: 'port-test' method: 'port-test'
}, function (data) { }, function (data) {
if (data.result == 'success') { if (data.result == 'success') {
if (data.arguments['port-is-open']) { labelPortOpenStatus(data.arguments['port-is-open']==true);
thisDialog.find('#system-config-port-is-open-true').fadeInAndOut();
} else {
thisDialog.find('#system-config-port-is-open-false').fadeInAndOut();
}
} }
button.linkbutton({ buttonPortTestStatus(true);
text: system.lang.dialog['system-config']['test-port'],
disabled: false
});
}); });
} else {
buttonPortTestStatus(true);
} }
}); });
} else { } else {
@ -733,16 +743,9 @@
method: 'port-test' method: 'port-test'
}, function (data) { }, function (data) {
if (data.result == 'success') { if (data.result == 'success') {
if (data.arguments['port-is-open']) { labelPortOpenStatus(data.arguments['port-is-open']==true);
thisDialog.find('#system-config-port-is-open-true').fadeInAndOut();
} else {
thisDialog.find('#system-config-port-is-open-false').fadeInAndOut();
}
button.linkbutton({
text: system.lang.dialog['system-config']['test-port'],
disabled: false
});
} }
buttonPortTestStatus(true);
}); });
} }
}); });