Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
709552f1
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
709552f1
编写于
4月 02, 2017
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Fixture] 添加首页
上级
66a2262e
变更
16
展开全部
隐藏空白更改
内联
并排
Showing
16 changed file
with
597 addition
and
538 deletion
+597
-538
apps/assets/models/user.py
apps/assets/models/user.py
+3
-0
apps/assets/templates/assets/asset_detail.html
apps/assets/templates/assets/asset_detail.html
+35
-0
apps/assets/templates/assets/asset_tag_create.html
apps/assets/templates/assets/asset_tag_create.html
+0
-124
apps/assets/templates/assets/asset_tag_detail.html
apps/assets/templates/assets/asset_tag_detail.html
+0
-277
apps/assets/templates/assets/asset_tags_list.html
apps/assets/templates/assets/asset_tags_list.html
+0
-125
apps/assets/templates/assets/asset_update.html
apps/assets/templates/assets/asset_update.html
+0
-1
apps/jumpserver/urls.py
apps/jumpserver/urls.py
+3
-2
apps/jumpserver/views.py
apps/jumpserver/views.py
+70
-0
apps/ops/templates/ops/task_detail.html
apps/ops/templates/ops/task_detail.html
+1
-1
apps/perms/api.py
apps/perms/api.py
+2
-2
apps/templates/_base_list.html
apps/templates/_base_list.html
+1
-1
apps/templates/_nav.html
apps/templates/_nav.html
+1
-1
apps/templates/index.html
apps/templates/index.html
+478
-0
apps/users/templates/users/user_group_detail.html
apps/users/templates/users/user_group_detail.html
+1
-1
requirements/requirements.txt
requirements/requirements.txt
+1
-2
utils/clean_migrations.sh
utils/clean_migrations.sh
+1
-1
未找到文件。
apps/assets/models/user.py
浏览文件 @
709552f1
...
...
@@ -254,3 +254,6 @@ class SystemUser(models.Model):
except
IntegrityError
:
print
(
'Error continue'
)
continue
apps/assets/templates/assets/asset_detail.html
浏览文件 @
709552f1
...
...
@@ -225,6 +225,41 @@
</table>
</div>
</div>
<div
class=
"panel panel-warning"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'System users' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table group_edit"
id=
"add-asset2systemuser"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select system user' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for system_user in system_users_remain %}
<option
value=
"{{ system_user.id }}"
id=
"opt_{{ system_user.id }}"
>
{{ system_user.name }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-warning btn-sm btn-system-user"
>
{% trans 'Associate' %}
</button>
</td>
</tr>
</form>
{% for system_user in system_users %}
<tr>
<td
><b
class=
"bdg_group"
data-sid=
{{
system_user.id
}}
>
{{ system_user.name }}
</b></td>
<td>
<button
class=
"btn btn-danger btn-xs pull-right btn_leave_system"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>
</div>
...
...
apps/assets/templates/assets/asset_tag_create.html
已删除
100644 → 0
浏览文件 @
66a2262e
{% extends 'base.html' %}
{% load i18n %}
{% load static %}
{% load bootstrap %}
{% block custom_head_css_js %}
<link
href=
"{% static 'css/plugins/select2/select2.min.css' %}"
rel=
"stylesheet"
>
<script
src=
"{% static 'js/plugins/select2/select2.full.min.js' %}"
></script>
<style>
div
.dataTables_wrapper
div
.dataTables_filter
,
.dataTables_length
{
float
:
left
;
}
</style>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-10"
>
<div
class=
"ibox float-e-margins"
>
<div
id=
"ibox-content"
class=
"ibox-title"
>
<h5>
{{ action }}
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"panel blank-panel"
>
<div
class=
"panel-body"
>
<div
class=
"tab-content"
>
<div
id=
"tab-1"
class=
"ibox float-e-margins tab-pane active"
></div>
<form
id=
"tagForm"
method=
"post"
class=
"form-horizontal"
>
{% csrf_token %}
<h3
class=
"widget-head-color-box"
>
基本信息
</h3>
{{ form.name|bootstrap_horizontal }}
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
id=
"asset_on_count"
>
关联的资产({{ assets_count }})
</label>
<div
class=
"col-sm-9"
id=
"asset_sed"
>
<div
class=
"form-asset-on"
id=
"add_asset"
>
<p
id=
"asset_on_p"
>
{% for asset in assets_on_list %}
<button
name=
'asset_hostname'
title=
'{{ asset.ip}}'
type=
'button'
class=
'btn btn-default btn-xs'
>
{{ asset.hostname }}
</button>
{% endfor %}
</p>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-5"
>
<button
class=
"btn btn-white"
type=
"reset"
>
重置
</button>
<button
class=
"btn btn-primary"
type=
"submit"
>
提交
</button>
<div
id=
'box2'
>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 模态框(Modal) -->
<div
class=
"modal fade"
id=
"modal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog modal-lg"
>
<div
class=
"modal-content"
id=
"box"
>
<!--此部分为主体内容,将远程加载进来-->
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
();
$
(
'
.select2-system-user
'
).
select2
();
})
$
(
'
#add_asset
'
).
on
(
'
click
'
,
function
(){
$
(
'
#modal
'
).
modal
(
'
show
'
);
});
$
(
'
#modal
'
).
modal
({
show
:
false
,
backdrop
:
'
static
'
,
keyboard
:
'
false
'
,
remote
:
"
{% url 'assets:asset-modal-list' %}?tag_id={{ tag_id }}
"
,
});
$
(
'
#modal
'
).
on
(
'
show.bs.modal
'
,
function
(){
//alert('当调用show方法时,立即触发;')
});
$
(
'
#modal
'
).
on
(
'
shown.bs.modal
'
,
function
(){
//alert('当弹窗完全加载完后,再触发;')
});
$
(
'
#modal
'
).
on
(
'
hide.bs.modal
'
,
function
(){
//alert('当关闭时,立即触发;')
});
$
(
'
#modal
'
).
on
(
'
hidden.bs.modal
'
,
function
(){
//alert('当关完全关闭后,再触发;')
});
$
(
'
#modal
'
).
on
(
'
loaded.bs.modal
'
,
function
(){
//alert('当远程数据加载完毕后,再触发;')
});
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/asset_tag_detail.html
已删除
100644 → 0
浏览文件 @
66a2262e
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2.min.css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2.full.min.js
"
%}"
></script>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li
class=
"active"
><a
href=
""
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label"
><b>
{{ asset_tag.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table"
>
<tbody>
<tr
class=
"no-borders-tr"
>
<td>
{% trans 'Tag Name' %}:
</td>
<td><b>
{{ asset_tag.name }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Created by' %}:
</td>
<td><b>
{{ asset_tag.created_by }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Date created' %}:
</td>
<td><b>
{{ asset_tag.created_time|date:"Y-m-d H:i:s" }}
</b></td>
</tr>
</tbody>
</table>
</div>
</div>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
></span>
{% trans 'Asset list of ' %}
<b>
{{ asset_tag.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table table-striped table-bordered table-hover "
id=
"tag_assets_table"
>
<thead>
<tr>
<th>
{% trans 'Hostname' %}
</th>
<th>
{% trans 'IP' %}
</th>
<th>
{% trans 'Port' %}
</th>
<th>
{% trans 'Type' %}
</th>
<th>
{% trans 'Valid' %}
</th>
<th>
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Add asset to this tag' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset in assets_remain %}
<option
value=
"{{ asset.id }}"
>
{{ asset.ip }}:{{ asset.port }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-info btn-sm btn-tag-asset-add"
>
{% trans 'Add' %}
</button>
</td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
jumpserver
.
assets_selected
=
{};
function
updateTagAssets
(
assets
)
{
var
the_url
=
"
{% url 'api-assets:tag-update-assets' pk=tag.id %}
"
;
var
body
=
{
assets
:
Object
.
assign
([],
assets
)
};
var
$data_table
=
$
(
"
#tag_assets_table
"
).
DataTable
();
var
success
=
function
(
data
)
{
$
(
'
.select2-selection__rendered
'
).
empty
();
$
.
map
(
jumpserver
.
assets_selected
,
function
(
asset_ip
,
index
)
{
$
(
'
#opt_
'
+
index
).
remove
();
$data_table
.
ajax
.
reload
();
});
jumpserver
.
groups_selected
=
{};
};
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
),
method
:
'
PUT
'
,
success
:
success
});
}
function
deleteTagAssets
(
obj
,
name
,
url
,
data
)
{
function
doDelete
()
{
var
body
=
data
;
var
success
=
function
()
{
swal
(
'
Deleted!
'
,
"
[
"
+
name
+
"
]
"
+
"
has been deleted
"
,
"
success
"
);
$
(
obj
).
parent
().
parent
().
remove
();
};
var
fail
=
function
()
{
swal
(
"
Failed
"
,
"
Delete
"
+
"
[
"
+
name
+
"
]
"
+
"
failed
"
,
"
error
"
);
};
APIUpdateAttr
({
url
:
url
,
body
:
JSON
.
stringify
(
body
),
method
:
'
PATCH
'
,
success
:
success
,
error
:
fail
});
}
swal
({
title
:
'
Are you sure delete ?
'
,
text
:
"
[
"
+
name
+
"
]
"
,
type
:
"
warning
"
,
showCancelButton
:
true
,
cancelButtonText
:
'
Cancel
'
,
confirmButtonColor
:
"
#DD6B55
"
,
confirmButtonText
:
'
Confirm
'
,
closeOnConfirm
:
false
},
function
()
{
doDelete
()
});
}
Array
.
prototype
.
remove
=
function
(
val
)
{
var
index
=
this
.
indexOf
(
val
);
if
(
index
>
-
1
)
{
this
.
splice
(
index
,
1
);
}
};
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
()
.
on
(
"
select2:select
"
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
assets_selected
[
data
.
id
]
=
data
.
text
;
})
.
on
(
'
select2:unselect
'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
delete
jumpserver
.
assets_selected
[
data
.
id
];
});
var
options
=
{
ele
:
$
(
'
#tag_assets_table
'
),
buttons
:
[],
order
:
[],
columnDefs
:
[
{
targets
:
0
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'
<a href="{% url "assets:asset-detail" pk=99991937 %}" data-aid="
'
+
rowData
.
id
+
'
">
'
+
cellData
+
'
</a>
'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'
99991937
'
,
rowData
.
id
));
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
)
{
if
(
!
cellData
)
{
$
(
td
).
html
(
'
<i class="fa fa-times text-danger"></i>
'
)
}
else
{
$
(
td
).
html
(
'
<i class="fa fa-check text-navy"></i>
'
)
}
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'
<a href="{% url "assets:asset-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>
'
.
replace
(
'
99991937
'
,
rowData
.
id
);
var
del_btn
=
'
<a class="btn btn-xs btn-danger m-l-xs btn_asset_delete" data-aid="99991937">{% trans "Delete" %}</a>
'
.
replace
(
'
99991937
'
,
rowData
.
id
);
$
(
td
).
html
(
update_btn
+
del_btn
)
}}
],
ajax_url
:
'
{% url "api-assets:asset-list" %}?tag_id={{ tag.id }}
'
,
columns
:
[{
data
:
"
hostname
"
},
{
data
:
"
ip
"
},
{
data
:
"
port
"
},
{
data
:
"
type
"
},
{
data
:
"
is_active
"
},
{
data
:
"
id
"
}],
op_html
:
$
(
'
#actions
'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
})
.
on
(
'
click
'
,
'
.btn-tag-asset-add
'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
assets_selected
).
length
===
0
)
{
return
false
;
}
var
assets
=
[];
var
$data_table
=
$
(
"
#tag_assets_table
"
).
DataTable
();
$
.
ajax
({
url
:
'
{% url "api-assets:asset-list" %}
'
,
method
:
'
GET
'
,
data
:
{
"
tag_id
"
:
{{
tag
.
id
}}},
dataType
:
'
json
'
,
success
:
function
(
result
)
{
for
(
var
i
in
result
){
if
(
!
isNaN
(
parseInt
(
result
[
i
][
'
id
'
])))
{
assets
.
push
(
parseInt
(
result
[
i
][
'
id
'
]))
}
}
$
.
map
(
jumpserver
.
assets_selected
,
function
(
value
,
index
)
{
assets
.
push
(
parseInt
(
index
));
});
updateTagAssets
(
assets
);
$data_table
.
ajax
().
reload
();
}
})
})
.
on
(
'
click
'
,
'
.btn_asset_delete
'
,
function
()
{
var
$this
=
$
(
this
);
var
the_url
=
"
{% url 'api-assets:tag-update-assets' pk=tag.id %}
"
;
var
name
=
$
(
this
).
closest
(
"
tr
"
).
find
(
"
:nth-child(1) > a
"
).
html
();
var
assets
=
[];
$
(
'
#tag_assets_table > tbody > tr
'
).
map
(
function
()
{
assets
.
push
(
parseInt
(
$
(
this
).
closest
(
"
tr
"
).
find
(
"
:nth-child(1) > a
"
).
attr
(
"
data-aid
"
)))
});
var
delete_asset_id
=
$
(
this
).
data
(
'
aid
'
);
assets
.
remove
(
delete_asset_id
);
var
data
=
{
"
assets
"
:
assets
};
deleteTagAssets
(
$this
,
name
,
the_url
,
data
);
});
</script>
{% endblock %}
apps/assets/templates/assets/asset_tags_list.html
已删除
100644 → 0
浏览文件 @
66a2262e
{% extends '_base_list.html' %}
{% load i18n static %}
{% block custom_head_css_js %}
<link
href=
"{% static 'css/plugins/select2/select2.min.css' %}"
rel=
"stylesheet"
>
<script
src=
"{% static 'js/plugins/select2/select2.full.min.js' %}"
></script>
{% endblock %}
{#{% block content_left_head %}#}
{#
<a
href=
"{% url 'assets:asset-tag-create' %}"
class=
"btn btn-sm btn-primary "
>
{% trans "Create tag" %}
</a>
#}
{#{% endblock %}#}
{#{% block table_head %}#}
{#
<th
class=
"text-center"
>
#}
{#
<input
type=
"checkbox"
id=
"check_all"
onclick=
"checkAll('check_all', 'checked')"
>
#}
{#
</th>
#}
{#
<th
class=
"text-center"
><a
href=
"{% url 'assets:asset-tag-list' %}?sort=name"
>
{% trans 'Tag Name' %}
</a></th>
#}
{#
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
#}
{#
<th
class=
"text-center"
></th>
#}
{#{% endblock %}#}
{#{% block table_body %}#}
{# {% for asset_tag in asset_tags_list %}#}
{#
<tr
class=
"gradeX"
>
#}
{#
<td
class=
"text-center"
>
#}
{#
<input
type=
"checkbox"
name=
"checked"
value=
"{{ asset_tag.id }}"
>
#}
{#
</td>
#}
{#
<td
class=
"text-center"
>
#}
{#
<a
href=
"{% url 'assets:asset-tag-detail' pk=asset_tag.id %}"
>
#}
{# {{ asset_tag.name }}#}
{#
</a>
#}
{#
</td>
#}
{#
<td
class=
"text-center"
>
{{ asset_tag.asset_set.count }}
</td>
#}
{#
<td
class=
"text-center"
>
#}
{#
<a
href=
"{% url 'assets:asset-tag-update' pk=asset_tag.id %}"
class=
"btn btn-xs btn-info"
>
{% trans 'Update' %}
</a>
#}
{#
<a
onclick=
"objectDelete(this,'{{ asset_tag.name }}','{% url 'assets:asset-tag-delete' asset_tag.id %}')"
class=
"btn btn-xs btn-danger del"
>
{% trans 'Delete' %}
</a>
#}
{#
</td>
#}
{#
</tr>
#}
{# {% endfor %}#}
{#{% endblock %}#}
{#{% block content_bottom_left %}#}
{#
<form
id=
""
method=
"get"
action=
""
class=
" mail-search"
>
#}
{#
<div
class=
"input-group"
>
#}
{#
<select
class=
"form-control m-b"
style=
"width: auto"
>
#}
{#
<option>
{% trans 'Delete selected' %}
</option>
#}
{#
<option>
{% trans 'Update selected' %}
</option>
#}
{#
<option>
{% trans 'Deactive selected' %}
</option>
#}
{#
<option>
{% trans 'Export selected' %}
</option>
#}
{#
</select>
#}
{#
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
#}
{#
<button
id=
'search_btn'
type=
"submit"
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
#}
{# {% trans 'Submit' %}#}
{#
</button>
#}
{#
</div>
#}
{#
</div>
#}
{#
</form>
#}
{#{% endblock %}#}
{% block table_search %}{% endblock %}
{% block table_container %}
<div
class=
"uc pull-left m-l-5 m-r-5"
>
<a
href=
"{% url "
assets:asset-tag-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create Tag" %}
</a>
</div>
<table
class=
"table table-striped table-bordered table-hover "
id=
"tag_list_table"
>
<thead>
<tr>
<th
class=
"text-center"
><input
type=
"checkbox"
class=
"ipt_check_all"
></th>
<th
class=
"text-center"
>
{% trans 'TagName' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div
id=
"actions"
class=
"hide"
>
<div
class=
"input-group"
>
<select
class=
"form-control m-b"
style=
"width: auto"
id=
"slct_bulk_update"
>
<option
value=
"delete"
>
{% trans 'Delete selected' %}
</option>
<option
value=
"update"
>
{% trans 'Update selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
var
options
=
{
ele
:
$
(
"
#tag_list_table
"
),
columnDefs
:[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'
<a href="{% url
'
assets
:
asset
-
tag
-
detail
'
pk=99991937 %}">
'
+
cellData
+
'
</a>
'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'
99991937
'
,
rowData
.
id
));
}},
{
targets
:
3
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'
<a href="{% url
'
assets
:
asset
-
tag
-
detail
'
pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>
'
.
replace
(
'
99991937
'
,
cellData
);
var
del_btn
=
'
<a class="btn btn-xs btn-danger m-l-xs btn_tag_delete" data-uid="99991937">{% trans "Delete" %}</a>
'
.
replace
(
'
99991937
'
,
cellData
);
$
(
td
).
html
(
update_btn
+
del_btn
)
}}
],
ajax_url
:
'
{% url "api-assets:asset-tag-list" %}
'
,
columns
:
[{
data
:
function
(){
return
""
}},
{
data
:
"
name
"
},
{
data
:
"
assets_amount
"
},{
data
:
"
id
"
}]
};
jumpserver
.
initDataTable
(
options
);
})
.
on
(
'
click
'
,
'
.btn_tag_delete
'
,
function
()
{
var
$this
=
$
(
this
);
var
$data_table
=
$
(
'
#tag_list_table
'
).
DataTable
();
var
name
=
$
(
this
).
closest
(
"
tr
"
).
find
(
"
:nth-child(2)
"
).
children
(
'
a
'
).
html
();
var
uid
=
$this
.
data
(
'
uid
'
);
var
the_url
=
'
{% url "api-assets:asset-tag-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
$data_table
.
ajax
.
reload
();
})
</script>
{% endblock %}
apps/assets/templates/assets/asset_update.html
浏览文件 @
709552f1
...
...
@@ -46,7 +46,6 @@
<h3>
{% trans 'Other' %}
</h3>
{{ form.status|bootstrap_horizontal }}
{{ form.env|bootstrap_horizontal }}
{{ form.tags|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }}
{{ form.is_active|bootstrap_horizontal }}
...
...
apps/jumpserver/urls.py
浏览文件 @
709552f1
...
...
@@ -19,12 +19,13 @@ Including another URLconf
from
django.conf.urls
import
url
,
include
from
django.conf
import
settings
from
django.conf.urls.static
import
static
from
django.views.generic.base
import
TemplateView
from
.views
import
IndexView
urlpatterns
=
[
url
(
r
'^captcha/'
,
include
(
'captcha.urls'
)),
url
(
r
'^$'
,
TemplateView
.
as_view
(
template_name
=
'base.html'
),
name
=
'index'
),
url
(
r
'^$'
,
IndexView
.
as_view
(
),
name
=
'index'
),
url
(
r
'^users/'
,
include
(
'users.urls.views_urls'
,
namespace
=
'users'
)),
url
(
r
'^assets/'
,
include
(
'assets.urls.views_urls'
,
namespace
=
'assets'
)),
url
(
r
'^perms/'
,
include
(
'perms.urls.views_urls'
,
namespace
=
'perms'
)),
...
...
apps/jumpserver/views.py
浏览文件 @
709552f1
from
django.views.generic
import
TemplateView
from
django.utils
import
timezone
from
django.db.models
import
Count
from
users.utils
import
AdminUserRequiredMixin
from
users.models
import
User
from
assets.models
import
Asset
from
audits.models
import
ProxyLog
class
IndexView
(
AdminUserRequiredMixin
,
TemplateView
):
template_name
=
'index.html'
def
get_context_data
(
self
,
**
kwargs
):
seven_days_ago
=
timezone
.
now
()
-
timezone
.
timedelta
(
days
=
7
)
month_ago
=
timezone
.
now
()
-
timezone
.
timedelta
(
days
=
30
)
proxy_log_seven_days
=
ProxyLog
.
objects
.
filter
(
date_start__gt
=
seven_days_ago
,
is_failed
=
False
)
proxy_log_month
=
ProxyLog
.
objects
.
filter
(
date_start__gt
=
month_ago
,
is_failed
=
False
)
month_dates
=
proxy_log_month
.
dates
(
'date_start'
,
'day'
)
month_total_visit
=
[
ProxyLog
.
objects
.
filter
(
date_start__date
=
d
)
for
d
in
month_dates
]
month_str
=
[
d
.
strftime
(
'%m-%d'
)
for
d
in
month_dates
]
month_total_visit_count
=
[
p
.
count
()
for
p
in
month_total_visit
]
month_user
=
[
p
.
values
(
'user'
).
distinct
().
count
()
for
p
in
month_total_visit
]
month_asset
=
[
p
.
values
(
'asset'
).
distinct
().
count
()
for
p
in
month_total_visit
]
month_user_active
=
User
.
objects
.
filter
(
last_login__gt
=
month_ago
).
count
()
month_user_inactive
=
User
.
objects
.
filter
(
last_login__lt
=
month_ago
).
count
()
month_user_disabled
=
User
.
objects
.
filter
(
is_active
=
False
).
count
()
month_asset_active
=
proxy_log_month
.
values
(
'asset'
).
distinct
().
count
()
month_asset_inactive
=
Asset
.
objects
.
all
().
count
()
-
month_asset_active
month_asset_disabled
=
Asset
.
objects
.
filter
(
is_active
=
False
).
count
()
week_asset_hot_ten
=
list
(
proxy_log_seven_days
.
values
(
'asset'
).
annotate
(
total
=
Count
(
'asset'
)).
order_by
(
'-total'
)[:
10
])
for
p
in
week_asset_hot_ten
:
last_login
=
ProxyLog
.
objects
.
filter
(
asset
=
p
[
'asset'
]).
order_by
(
'date_start'
).
last
()
p
[
'last'
]
=
last_login
last_login_ten
=
ProxyLog
.
objects
.
all
().
order_by
(
'-date_start'
)[:
10
]
for
p
in
last_login_ten
:
try
:
p
.
avatar_url
=
User
.
objects
.
get
(
username
=
p
.
user
).
avatar_url
()
except
User
.
DoesNotExist
:
p
.
avatar_url
=
User
.
objects
.
first
().
avatar_url
()
week_user_hot_ten
=
list
(
proxy_log_seven_days
.
values
(
'user'
).
annotate
(
total
=
Count
(
'user'
)).
order_by
(
'-total'
)[:
10
])
for
p
in
week_user_hot_ten
:
last_login
=
ProxyLog
.
objects
.
filter
(
user
=
p
[
'user'
]).
order_by
(
'date_start'
).
last
()
p
[
'last'
]
=
last_login
context
=
{
'assets_count'
:
Asset
.
objects
.
count
(),
'users_count'
:
User
.
objects
.
filter
(
role__in
=
(
'Admin'
,
'User'
)).
count
(),
'online_user_count'
:
ProxyLog
.
objects
.
filter
(
is_finished
=
False
).
values
(
'user'
).
distinct
().
count
(),
'online_asset_count'
:
ProxyLog
.
objects
.
filter
(
is_finished
=
False
).
values
(
'asset'
).
distinct
().
count
(),
'user_visit_count_weekly'
:
proxy_log_seven_days
.
values
(
'user'
).
distinct
().
count
(),
'asset_visit_count_weekly'
:
proxy_log_seven_days
.
count
(),
'user_visit_count_top_five'
:
proxy_log_seven_days
.
values
(
'user'
).
annotate
(
total
=
Count
(
'user'
)).
order_by
(
'-total'
)[:
5
],
'month_str'
:
month_str
,
'month_total_visit_count'
:
month_total_visit_count
,
'month_user'
:
month_user
,
'mouth_asset'
:
month_asset
,
'month_user_active'
:
month_user_active
,
'month_user_inactive'
:
month_user_inactive
,
'month_user_disabled'
:
month_user_disabled
,
'month_asset_active'
:
month_asset_active
,
'month_asset_inactive'
:
month_asset_inactive
,
'month_asset_disabled'
:
month_asset_disabled
,
'week_asset_hot_ten'
:
week_asset_hot_ten
,
'last_login_ten'
:
last_login_ten
,
'week_user_hot_ten'
:
week_user_hot_ten
,
}
kwargs
.
update
(
context
)
return
super
(
IndexView
,
self
).
get_context_data
(
**
kwargs
)
apps/ops/templates/ops/task_detail.html
浏览文件 @
709552f1
...
...
@@ -73,7 +73,7 @@
{% else %}
<td>
<div
class=
"progress progress-striped active"
>
<div
style=
"width: 50%"
aria-valuemax=
"100"
aria-valuemin=
"0"
aria-valuenow=
"75"
role=
"progressbar"
class=
"progress-bar progress-bar-
danger
"
>
<div
style=
"width: 50%"
aria-valuemax=
"100"
aria-valuemin=
"0"
aria-valuenow=
"75"
role=
"progressbar"
class=
"progress-bar progress-bar-
primary
"
>
<span
class=
"sr-only"
>
40% Complete (success)
</span>
</div>
</div>
...
...
apps/perms/api.py
浏览文件 @
709552f1
...
...
@@ -197,7 +197,7 @@ class MyAssetGroupAssetsApi(ListAPIView):
permission_classes
=
(
IsValidUser
,)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
asset_groups
=
{}
asset_groups
=
dict
()
asset_groups
[
0
]
=
{
'id'
:
0
,
'name'
:
'ungrouped'
,
'assets'
:
[]
}
...
...
@@ -216,7 +216,7 @@ class MyAssetGroupAssetsApi(ListAPIView):
asset_json
=
asset
.
to_json
()
asset_json
[
'system_users'
]
=
[
su
.
to_json
()
for
su
in
system_users
]
if
not
asset
.
groups
.
all
():
asset_groups
[
0
][
assets
].
append
(
asset_json
)
asset_groups
[
0
][
'assets'
].
append
(
asset_json
)
continue
for
asset_group
in
asset
.
groups
.
all
():
if
asset_group
.
id
in
asset_groups
:
...
...
apps/templates/_base_list.html
浏览文件 @
709552f1
{% extends 'base.html' %}
{% load static %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
dataTables
/
data
T
ables.min.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
dataTables
/
data
t
ables.min.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
awesome-bootstrap-checkbox
/
awesome-bootstrap-checkbox.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2.min.css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2.full.min.js
"
%}"
></script>
...
...
apps/templates/_nav.html
浏览文件 @
709552f1
{% load i18n %}
<li
id=
"index"
>
<a
href=
""
>
<a
href=
"
{% url 'index' %}
"
>
<i
class=
"fa fa-dashboard"
></i>
<span
class=
"nav-label"
>
{% trans 'Home' %}
</span><span
class=
"label label-info pull-right"
></span>
</a>
</li>
...
...
apps/templates/index.html
浏览文件 @
709552f1
此差异已折叠。
点击以展开。
apps/users/templates/users/user_group_detail.html
浏览文件 @
709552f1
...
...
@@ -5,7 +5,7 @@
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2.min.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
sweetalert
/
sweetalert.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
dataTables
/
data
T
ables.min.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
dataTables
/
data
t
ables.min.css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
awesome-bootstrap-checkbox
/
awesome-bootstrap-checkbox.css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2.full.min.js
"
%}"
></script>
<script
src=
"{% static "
js
/
plugins
/
sweetalert
/
sweetalert.min.js
"
%}"
></script>
...
...
requirements/requirements.txt
浏览文件 @
709552f1
...
...
@@ -7,7 +7,7 @@ ForgeryPy==0.1
openpyxl==2.4.0
celery==3.1.23
paramiko==2.1.1
ansible==2.
1
.2.0
ansible==2.
2
.2.0
django-simple-captcha==0.5.2
django-formtools==1.0
sshpubkeys==2.2.0
...
...
@@ -20,4 +20,3 @@ tornado==4.4.2
eventlet==0.20.1
django-filter==1.0.0
passlib==1.7.1
sshpass
utils/clean_migrations.sh
浏览文件 @
709552f1
...
...
@@ -2,5 +2,5 @@
#
for
app
in
users
assets perms audits ops applications
;
do
rm
-f
../apps/
$app
/migrations/00
0
*
rm
-f
../apps/
$app
/migrations/00
*
done
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录