[Update] 创建系统用户选择rdp协议,去掉相关配置的一些无用功能

pull/1331/head
BaiJiangJie 2018-05-15 12:52:53 +08:00
parent 38f8c5bb72
commit 718715cc6d
3 changed files with 44 additions and 23 deletions

View File

@ -55,7 +55,7 @@
{% bootstrap_field form.private_key_file layout="horizontal" %}
</div>
<div class="form-group">
<label for="{{ form.as_push.id_for_label }}" class="col-sm-2 control-label">{% trans 'Auto push' %}</label>
<label for="{{ form.auto_push.id_for_label }}" class="col-sm-2 control-label">{% trans 'Auto push' %}</label>
<div class="col-sm-8">
{{ form.auto_push}}
</div>
@ -82,13 +82,11 @@
<script>
var auto_generate_key = '#'+'{{ form.auto_generate_key.id_for_label }}';
var protocol_id = '#' + '{{ form.protocol.id_for_label }}';
var password_id = '#' + '{{ form.password.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, sudo_id, shell_id] ;
function authFieldsDisplay() {
if ($(auto_generate_key).prop('checked')) {
$('.auth-fields').addClass('hidden');
@ -98,24 +96,42 @@
}
function protocolChange() {
if ($(protocol_id).attr('value') === 'rdp') {
$.each(need_change_field, function (index, value) {
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
];
if ($(protocol_id + " option:selected").text() === 'rdp') {
$('.auth-fields').removeClass('hidden');
$.each(need_change_div, function (index, value) {
$(value).addClass('hidden')
});
$(password_id).removeClass('hidden')
} else {
$.each(need_change_field, function (index, value) {
authFieldsDisplay();
$.each(need_change_div, function (index, value) {
$(value).removeClass('hidden')
});
}
}
$(document).ready(function () {
$('.select2').select2();
authFieldsDisplay();
protocolChange();
$(auto_generate_key).change(function () {
{% block document_ready %}
$(document).ready(function () {
$('.select2').select2();
authFieldsDisplay();
protocolChange();
});
})
{% endblock %}
$(protocol_id).change(function (){
protocolChange();
});
$(auto_generate_key).change(function () {
authFieldsDisplay();
});
</script>
{% endblock %}

View File

@ -64,14 +64,14 @@
</tr>
<tr>
<td>{% trans 'Protocol' %}:</td>
<td><b>{{ system_user.protocol }}</b></td>
<td><b id="id_protocol_type">{{ system_user.protocol }}</b></td>
</tr>
<tr>
<tr id="id_sudo">
<td>{% trans 'Sudo' %}:</td>
<td><b>{{ system_user.sudo }}</b></td>
</tr>
{% if system_user.shell %}
<tr>
<tr id="id_shell">
<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">
<div class="panel panel-primary" id="id_quick_update">
<div class="panel-heading">
<i class="fa fa-info-circle"></i> {% trans 'Quick update' %}
</div>
@ -236,6 +236,12 @@ 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');
}
$('.select2').select2()
.on('select2:select', function(evt) {
var data = evt.params.data;

View File

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