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 () {
var button = $(this);
button.linkbutton({
text: system.lang.dialog['system-config'].testing,
disabled: true
});
var newPort = parseInt(thisDialog.find('#peer-port').val());
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({
method: 'session-set',
arguments: {
'peer-port': true
'peer-port': newPort
}
}, function (data) {
if (data.result == 'success') {
system.serverConfig['peer-port'] = newPort;
transmission.exec({
method: 'port-test'
}, function (data) {
if (data.result == 'success') {
if (data.arguments['port-is-open']) {
thisDialog.find('#system-config-port-is-open-true').fadeInAndOut();
} else {
thisDialog.find('#system-config-port-is-open-false').fadeInAndOut();
}
labelPortOpenStatus(data.arguments['port-is-open']==true);
}
button.linkbutton({
text: system.lang.dialog['system-config']['test-port'],
disabled: false
});
buttonPortTestStatus(true);
});
} else {
buttonPortTestStatus(true);
}
});
} else {
@ -733,16 +743,9 @@
method: 'port-test'
}, function (data) {
if (data.result == 'success') {
if (data.arguments['port-is-open']) {
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
});
labelPortOpenStatus(data.arguments['port-is-open']==true);
}
buttonPortTestStatus(true);
});
}
});