Commit 718715cc authored by BaiJiangJie's avatar BaiJiangJie

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

parent 38f8c5bb
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
{% bootstrap_field form.private_key_file layout="horizontal" %} {% bootstrap_field form.private_key_file layout="horizontal" %}
</div> </div>
<div class="form-group"> <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"> <div class="col-sm-8">
{{ form.auto_push}} {{ form.auto_push}}
</div> </div>
...@@ -82,13 +82,11 @@ ...@@ -82,13 +82,11 @@
<script> <script>
var auto_generate_key = '#'+'{{ form.auto_generate_key.id_for_label }}'; var auto_generate_key = '#'+'{{ form.auto_generate_key.id_for_label }}';
var protocol_id = '#' + '{{ form.protocol.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 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 sudo_id = '#' + '{{ form.sudo.id_for_label }}';
var shell_id = '#' + '{{ form.shell.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() { function authFieldsDisplay() {
if ($(auto_generate_key).prop('checked')) { if ($(auto_generate_key).prop('checked')) {
$('.auth-fields').addClass('hidden'); $('.auth-fields').addClass('hidden');
...@@ -98,24 +96,42 @@ ...@@ -98,24 +96,42 @@
} }
function protocolChange() { function protocolChange() {
if ($(protocol_id).attr('value') === 'rdp') { var div_auto_generate_key = $(auto_generate_key).parent().parent();
$.each(need_change_field, function (index, value) { 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') $(value).addClass('hidden')
}); });
$(password_id).removeClass('hidden')
} else { } else {
$.each(need_change_field, function (index, value) { authFieldsDisplay();
$.each(need_change_div, function (index, value) {
$(value).removeClass('hidden') $(value).removeClass('hidden')
}); });
} }
} }
$(document).ready(function () {
$('.select2').select2(); {% block document_ready %}
authFieldsDisplay(); $(document).ready(function () {
protocolChange(); $('.select2').select2();
$(auto_generate_key).change(function () {
authFieldsDisplay(); authFieldsDisplay();
protocolChange();
}); });
}) {% endblock %}
$(protocol_id).change(function (){
protocolChange();
});
$(auto_generate_key).change(function () {
authFieldsDisplay();
});
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -64,14 +64,14 @@ ...@@ -64,14 +64,14 @@
</tr> </tr>
<tr> <tr>
<td>{% trans 'Protocol' %}:</td> <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> <tr id="id_sudo">
<td>{% trans 'Sudo' %}:</td> <td>{% trans 'Sudo' %}:</td>
<td><b>{{ system_user.sudo }}</b></td> <td><b>{{ system_user.sudo }}</b></td>
</tr> </tr>
{% if system_user.shell %} {% if system_user.shell %}
<tr> <tr id="id_shell">
<td>{% trans 'Shell' %}:</td> <td>{% trans 'Shell' %}:</td>
<td><b>{{ system_user.shell }}</b></td> <td><b>{{ system_user.shell }}</b></td>
</tr> </tr>
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
</div> </div>
<div class="col-sm-4" style="padding-left: 0;padding-right: 0"> <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"> <div class="panel-heading">
<i class="fa fa-info-circle"></i> {% trans 'Quick update' %} <i class="fa fa-info-circle"></i> {% trans 'Quick update' %}
</div> </div>
...@@ -236,6 +236,12 @@ function updateSystemUserNode(nodes) { ...@@ -236,6 +236,12 @@ function updateSystemUserNode(nodes) {
} }
jumpserver.nodes_selected = {}; jumpserver.nodes_selected = {};
$(document).ready(function () { $(document).ready(function () {
if($('#id_protocol_type').text() === 'rdp'){
$('#id_quick_update').addClass('hidden');
$('#id_sudo').addClass('hidden');
$('#id_shell').addClass('hidden');
}
$('.select2').select2() $('.select2').select2()
.on('select2:select', function(evt) { .on('select2:select', function(evt) {
var data = evt.params.data; var data = evt.params.data;
......
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
</div> </div>
{% endblock %} {% endblock %}
{% block custom_foot_js %} {% block document_ready %}
<script>
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2();
}) protocolChange();
</script> });
{% endblock %} {% endblock %}
\ No newline at end of file
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