[Update] 修改前端rdp相关配置的选择逻辑

pull/1333/head
BaiJiangJie 7 years ago
parent 599431f402
commit ac67c231fc

@ -86,52 +86,43 @@
var auto_push_id = '#' + '{{ form.auto_push.id_for_label }}';
var sudo_id = '#' + '{{ form.sudo.id_for_label }}';
var shell_id = '#' + '{{ form.shell.id_for_label }}';
var div_auto_generate_key = $(auto_generate_key).parent().parent();
var div_ssh_private_key = $(private_key_id).parent().parent().parent().parent();
var div_auto_push = $(auto_push_id).parent().parent();
var div_sudo = $(sudo_id).parent().parent();
var div_shell = $(shell_id).parent().parent();
var need_change_div = [
div_auto_generate_key, div_ssh_private_key,
div_auto_push, div_sudo, div_shell
var need_change_field = [
auto_generate_key, private_key_id, auto_push_id, sudo_id, shell_id
];
function authFieldsDisplay() {
if ($(auto_generate_key).prop('checked')) {
$('.auth-fields').addClass('hidden');
} else {
$('.auth-fields').removeClass('hidden');
}
}
function protocolChange() {
if ($(protocol_id + " option:selected").text() === 'rdp') {
$('.auth-fields').removeClass('hidden');
$.each(need_change_div, function (index, value) {
$(value).addClass('hidden')
$.each(need_change_field, function (index, value) {
$(value).closest('.form-group').addClass('hidden')
});
} else {
authFieldsDisplay();
$.each(need_change_div, function (index, value) {
$(value).removeClass('hidden')
$.each(need_change_field, function (index, value) {
$(value).closest('.form-group').removeClass('hidden')
});
}
}
{% block document_ready %}
function authFieldsDisplay() {
if ($(auto_generate_key).prop('checked')) {
$('.auth-fields').addClass('hidden');
} else {
$('.auth-fields').removeClass('hidden');
}
}
$(document).ready(function () {
$('.select2').select2();
authFieldsDisplay();
protocolChange();
});
{% endblock %}
$(protocol_id).change(function (){
})
.on('change', protocol_id, function(){
protocolChange();
});
$(auto_generate_key).change(function () {
})
.on('change', auto_generate_key, function(){
authFieldsDisplay();
});
</script>
{% endblock %}

@ -72,22 +72,21 @@
var protocol_id = '#' + '{{ form.protocol.id_for_label }}';
var private_key_id = '#' + '{{ form.private_key_file.id_for_label }}';
var port = '#' + '{{ form.port.id_for_label }}';
var div_ssh_private_key = $(private_key_id).parent().parent().parent().parent();
function protocolChange() {
if ($(protocol_id + " option:selected").text() === 'rdp') {
$(port).val(3389);
$(div_ssh_private_key).addClass('hidden')
$(private_key_id).closest('.form-group').addClass('hidden')
} else {
$(port).val(22);
$(div_ssh_private_key).removeClass('hidden')
$(private_key_id).closest('.form-group').removeClass('hidden')
}
}
$(document).ready(function(){
protocolChange();
});
$(protocol_id).change(function (){
})
.on('change', protocol_id, function(){
protocolChange();
});
</script>

@ -66,12 +66,12 @@
<td>{% trans 'Protocol' %}:</td>
<td><b id="id_protocol_type">{{ system_user.protocol }}</b></td>
</tr>
<tr id="id_sudo">
<tr class="only-ssh">
<td>{% trans 'Sudo' %}:</td>
<td><b>{{ system_user.sudo }}</b></td>
</tr>
{% if system_user.shell %}
<tr id="id_shell">
<tr class="only-ssh">
<td>{% trans 'Shell' %}:</td>
<td><b>{{ system_user.shell }}</b></td>
</tr>
@ -107,7 +107,7 @@
</div>
<div class="col-sm-4" style="padding-left: 0;padding-right: 0">
<div class="panel panel-primary" id="id_quick_update">
<div class="panel panel-primary only-ssh">
<div class="panel-heading">
<i class="fa fa-info-circle"></i> {% trans 'Quick update' %}
</div>
@ -237,11 +237,8 @@ function updateSystemUserNode(nodes) {
jumpserver.nodes_selected = {};
$(document).ready(function () {
if($('#id_protocol_type').text() === 'rdp'){
$('#id_quick_update').addClass('hidden');
$('#id_sudo').addClass('hidden');
$('#id_shell').addClass('hidden');
$('.only-ssh').addClass('hidden')
}
$('.select2').select2()
.on('select2:select', function(evt) {
var data = evt.params.data;

@ -15,9 +15,3 @@
</div>
{% endblock %}
{% block document_ready %}
$(document).ready(function () {
$('.select2').select2();
protocolChange();
});
{% endblock %}

Loading…
Cancel
Save