Commit ac67c231 authored by BaiJiangJie's avatar BaiJiangJie

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

parent 599431f4
......@@ -79,59 +79,50 @@
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
var auto_generate_key = '#'+'{{ form.auto_generate_key.id_for_label }}';
var protocol_id = '#' + '{{ form.protocol.id_for_label }}';
var private_key_id = '#' + '{{ form.private_key_file.id_for_label }}';
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 }}';
<script>
var auto_generate_key = '#'+'{{ form.auto_generate_key.id_for_label }}';
var protocol_id = '#' + '{{ form.protocol.id_for_label }}';
var private_key_id = '#' + '{{ form.private_key_file.id_for_label }}';
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 need_change_field = [
auto_generate_key, private_key_id, auto_push_id, sudo_id, shell_id
];
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
];
function authFieldsDisplay() {
if ($(auto_generate_key).prop('checked')) {
$('.auth-fields').addClass('hidden');
} else {
$('.auth-fields').removeClass('hidden');
}
}
function protocolChange() {
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')
});
}
}
function authFieldsDisplay() {
if ($(auto_generate_key).prop('checked')) {
$('.auth-fields').addClass('hidden');
} else {
$('.auth-fields').removeClass('hidden');
}
}
{% block document_ready %}
$(document).ready(function () {
$(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>
});
</script>
{% endblock %}
\ No newline at end of file
......@@ -68,27 +68,26 @@
{% endblock %}
{% block custom_foot_js %}
<script>
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();
<script>
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 }}';
function protocolChange() {
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(){
$(document).ready(function(){
protocolChange();
});
$(protocol_id).change(function (){
})
.on('change', protocol_id, function(){
protocolChange();
});
</script>
});
</script>
{% endblock %}
\ No newline at end of file
......@@ -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 %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment