mirror of https://github.com/jumpserver/jumpserver
Merge branch 'dev' of git.coding.net:jumpserver/jumpserver into dev
commit
35db337f79
|
@ -69,33 +69,6 @@ def db_asset_add(**kwargs):
|
|||
asset.group = group_select
|
||||
|
||||
|
||||
#
|
||||
# def get_host_groups(groups):
|
||||
# """ 获取主机所属的组类 """
|
||||
# ret = []
|
||||
# for group_id in groups:
|
||||
# group = BisGroup.objects.filter(id=group_id)
|
||||
# if group:
|
||||
# group = group[0]
|
||||
# ret.append(group)
|
||||
# group_all = get_object_or_404(BisGroup, name='ALL')
|
||||
# ret.append(group_all)
|
||||
# return ret
|
||||
#
|
||||
#
|
||||
# # def get_host_depts(depts):
|
||||
# # """ 获取主机所属的部门类 """
|
||||
# # ret = []
|
||||
# # for dept_id in depts:
|
||||
# # dept = DEPT.objects.filter(id=dept_id)
|
||||
# # if dept:
|
||||
# # dept = dept[0]
|
||||
# # ret.append(dept)
|
||||
# # return ret
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
def db_asset_update(**kwargs):
|
||||
""" 修改主机时数据库操作函数 """
|
||||
asset_id = kwargs.pop('id')
|
||||
|
|
|
@ -16,9 +16,13 @@ ASSET_STATUS = (
|
|||
)
|
||||
|
||||
ASSET_TYPE = (
|
||||
(1, u"服务器"),
|
||||
(2, u"网络设备"),
|
||||
(3, u"其他")
|
||||
(1, u"物理机"),
|
||||
(2, u"虚拟机"),
|
||||
(3, u"交换机"),
|
||||
(4, u"路由器"),
|
||||
(5, u"防火墙"),
|
||||
(6, u"Docker"),
|
||||
(7, u"其他")
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -128,9 +128,10 @@ def asset_add(request):
|
|||
header_title, path1, path2 = u'添加资产', u'资产管理', u'添加资产'
|
||||
asset_group_all = AssetGroup.objects.all()
|
||||
af = AssetForm()
|
||||
default_setting = get_object(Setting, name='default')
|
||||
default_port = default_setting.field2 if default_setting else ''
|
||||
if request.method == 'POST':
|
||||
af_post = AssetForm(request.POST)
|
||||
print af_post
|
||||
ip = request.POST.get('ip', '')
|
||||
hostname = request.POST.get('hostname', '')
|
||||
is_active = True if request.POST.get('is_active') == '1' else False
|
||||
|
@ -147,7 +148,7 @@ def asset_add(request):
|
|||
asset_save = af_post.save(commit=False)
|
||||
if not use_default_auth:
|
||||
password = request.POST.get('password', '')
|
||||
password_encode = password
|
||||
password_encode = CRYPTOR.encrypt(password)
|
||||
asset_save.password = password_encode
|
||||
if not ip:
|
||||
asset_save.ip = hostname
|
||||
|
@ -227,9 +228,11 @@ def asset_edit(request):
|
|||
af_save.password = ''
|
||||
af_save.port = None
|
||||
else:
|
||||
if password_old != password:
|
||||
if password:
|
||||
password_encode = CRYPTOR.encrypt(password)
|
||||
af_save.password = password_encode
|
||||
else:
|
||||
af_save.password = password_old
|
||||
af_save.is_active = True if is_active else False
|
||||
af_save.save()
|
||||
af_post.save_m2m()
|
||||
|
@ -266,6 +269,7 @@ def asset_list(request):
|
|||
export = request.GET.get("export", False)
|
||||
group_id = request.GET.get("group_id", '')
|
||||
idc_id = request.GET.get("idc_id", '')
|
||||
asset_id_all = request.GET.getlist("id", '')
|
||||
if group_id:
|
||||
group = get_object(AssetGroup, id=group_id)
|
||||
if group:
|
||||
|
@ -302,6 +306,12 @@ def asset_list(request):
|
|||
Q(disk__contains=keyword))
|
||||
|
||||
if export:
|
||||
if asset_id_all:
|
||||
asset_find = []
|
||||
for asset_id in asset_id_all:
|
||||
asset = get_object(Asset, id=asset_id)
|
||||
if asset:
|
||||
asset_find.append(asset)
|
||||
s = write_excel(asset_find)
|
||||
if s[0]:
|
||||
file_name = s[1]
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -74,11 +74,11 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="id_port" style="display: none">
|
||||
<div class="form-group" id="id_port">
|
||||
<div class="hr-line-dashed"></div>
|
||||
<label class="col-sm-2 control-label"> 端口<span class="red-fonts">*</span> </label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" placeholder="Port" name="port" class="form-control">
|
||||
<input type="text" placeholder="Port" name="port" class="form-control" value="{{ default_port }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -122,11 +122,9 @@
|
|||
$('#id_use_default_auth').click(function(){
|
||||
if ($(this).is(':checked')){
|
||||
$('#admin_account').css('display', 'none');
|
||||
$('#id_port').css('display', 'none')
|
||||
}
|
||||
else {
|
||||
$('#admin_account').css('display', 'block');
|
||||
$('#id_port').css('display', 'block')
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -165,7 +163,7 @@
|
|||
msg: {required: "必须填写!"}
|
||||
},
|
||||
"port": {
|
||||
rule: "required(use_default_auth)",
|
||||
rule: "required",
|
||||
tip: "输入端口号",
|
||||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
|
|
|
@ -69,11 +69,11 @@
|
|||
|
||||
<label class="col-sm-1 control-label"> 密码<span class="red-fonts">*</span> </label>
|
||||
<div class="col-sm-4">
|
||||
<input type="password" value="{{ asset.password }}" name="password" class="form-control">
|
||||
<input type="password" value="" name="password" placeholder="不填写即不更改密码." class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" id="id_port" {% if asset.use_default_auth %} style="display: none" {% endif %}>
|
||||
<div class="form-group" id="id_port">
|
||||
<div class="hr-line-dashed"></div>
|
||||
<label class="col-sm-2 control-label"> 端口<span class="red-fonts">*</span> </label>
|
||||
<div class="col-sm-8">
|
||||
|
@ -172,11 +172,9 @@
|
|||
$('#id_use_default_auth').click(function(){
|
||||
if ($(this).is(':checked')){
|
||||
$('#admin_account').css('display', 'none');
|
||||
$('#id_port').css('display', 'none')
|
||||
}
|
||||
else {
|
||||
$('#admin_account').css('display', 'block');
|
||||
$('#id_port').css('display', 'block')
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -220,12 +218,12 @@
|
|||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
},
|
||||
"password": {
|
||||
rule: "required(use_default_auth)",
|
||||
tip: "输入密码",
|
||||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
}
|
||||
{# "password": {#}
|
||||
{# rule: "required(use_default_auth)",#}
|
||||
{# tip: "输入密码",#}
|
||||
{# ok: "",#}
|
||||
{# msg: {required: "必须填写!"}#}
|
||||
{# }#}
|
||||
},
|
||||
valid: function(form) {
|
||||
form.submit();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<div class="ibox-content">
|
||||
<form id="asset_form">
|
||||
<div class="col-sm-1" style="padding-left: 0">
|
||||
<a target="_blank" href="/jasset/group_add/" class="btn btn-sm btn-primary "> 添加资产 </a>
|
||||
<a target="_blank" href="/jasset/asset_add/" class="btn btn-sm btn-primary "> 添加资产 </a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-7" style="padding-left: 0px">
|
||||
|
@ -268,6 +268,7 @@
|
|||
shift: 'top',
|
||||
border: [2, 0.3, '#1AB394'],
|
||||
shade: [0.5, '#000000'],
|
||||
area: ['800px', '600px'],
|
||||
shadeClose: true,
|
||||
content: url,
|
||||
cancel: function(){
|
||||
|
@ -278,7 +279,6 @@
|
|||
|
||||
$('.search-btn-excel').unbind('click').bind('click',function(){
|
||||
var url= $(this).attr("href");
|
||||
console.log(url);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
|
|
Loading…
Reference in New Issue