Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
367ebebf
Commit
367ebebf
authored
Jul 29, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into api_key
parents
fe2840ed
74ae8636
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
76 additions
and
57 deletions
+76
-57
node.py
apps/assets/serializers/node.py
+3
-2
_asset_user_list.html
apps/assets/templates/assets/_asset_user_list.html
+2
-3
asset_list.html
apps/assets/templates/assets/asset_list.html
+1
-2
user_asset_list.html
apps/assets/templates/assets/user_asset_list.html
+1
-1
adhoc_history.html
apps/ops/templates/ops/adhoc_history.html
+1
-1
task_adhoc.html
apps/ops/templates/ops/task_adhoc.html
+2
-2
task_history.html
apps/ops/templates/ops/task_history.html
+3
-2
user_permission.py
apps/perms/api/user_permission.py
+6
-1
0002_auto_20171228_0025_squashed_0009_auto_20180903_1132.py
...02_auto_20171228_0025_squashed_0009_auto_20180903_1132.py
+3
-3
user_permission.py
apps/perms/serializers/user_permission.py
+1
-1
asset_permission.py
apps/perms/utils/asset_permission.py
+4
-2
forms.py
apps/settings/forms.py
+2
-2
jumpserver.js
apps/static/js/jumpserver.js
+32
-22
_foot_js.html
apps/templates/_foot_js.html
+1
-1
command_list.html
apps/terminal/templates/terminal/command_list.html
+5
-3
session_list.html
apps/terminal/templates/terminal/session_list.html
+7
-7
user_granted_asset.html
apps/users/templates/users/user_granted_asset.html
+1
-1
user_group_granted_asset.html
apps/users/templates/users/user_group_granted_asset.html
+1
-1
No files found.
apps/assets/serializers/node.py
View file @
367ebebf
...
...
@@ -14,13 +14,14 @@ __all__ = [
class
NodeSerializer
(
BulkOrgResourceModelSerializer
):
assets_amount
=
serializers
.
IntegerField
(
read_only
=
True
)
name
=
serializers
.
ReadOnlyField
(
source
=
'value'
)
class
Meta
:
model
=
Node
only_fields
=
[
'id'
,
'key'
,
'value'
,
'org_id'
]
fields
=
only_fields
+
[
'assets_amount'
]
fields
=
only_fields
+
[
'
name'
,
'
assets_amount'
]
read_only_fields
=
[
'key'
,
'assets_amount'
,
'org_id'
,
'key'
,
'
name'
,
'
assets_amount'
,
'org_id'
,
]
def
validate_value
(
self
,
data
):
...
...
apps/assets/templates/assets/_asset_user_list.html
View file @
367ebebf
...
...
@@ -51,8 +51,7 @@ function initAssetUserTable() {
}
else
{
innerHtml
=
'<i class="fa fa-circle text-warning"></i>'
}
var
date
=
new
Date
(
cellData
.
datetime
);
var
dateManual
=
date
.
toLocaleString
();
var
dateManual
=
toSafeLocalDateStr
(
cellData
.
datetime
);
var
dataContent
=
testDatetime
+
dateManual
;
innerHtml
=
"<a data-toggle='popover' data-content='"
+
dataContent
+
"'"
+
'data-placement="auto bottom"'
+
">"
+
innerHtml
+
"</a>"
;
$
(
td
).
html
(
innerHtml
);
...
...
@@ -60,7 +59,7 @@ function initAssetUserTable() {
},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
)
{
var
data
=
formatDateAsCN
(
cellData
);
var
data
=
toSafeLocalDateStr
(
cellData
);
$
(
td
).
html
(
data
);
},
},
...
...
apps/assets/templates/assets/asset_list.html
View file @
367ebebf
...
...
@@ -159,8 +159,7 @@ function initTable() {
}
else
{
innerHtml
=
'<i class="fa fa-circle text-warning"></i>'
}
var
date
=
new
Date
(
cellData
.
datetime
);
var
dateManual
=
date
.
toLocaleString
();
var
dateManual
=
toSafeLocalDateStr
(
cellData
.
datetime
);
var
dataContent
=
testDatetime
+
dateManual
;
innerHtml
=
"<a data-toggle='popover' data-content='"
+
dataContent
+
"'"
+
'data-placement="auto bottom"'
+
">"
+
innerHtml
+
"</a>"
;
$
(
td
).
html
(
innerHtml
);
...
...
apps/assets/templates/assets/user_asset_list.html
View file @
367ebebf
...
...
@@ -23,7 +23,7 @@
<script>
var
treeUrl
=
"{% url 'api-perms:my-nodes-as-tree' %}?&cache_policy=1"
;
var
assetTableUrl
=
"{% url 'api-perms:my-assets' %}?cache_policy=1"
;
var
selectUrl
=
'{% url "api-perms:my-node-assets" node_id=DEFAULT_PK %}?cache_policy=1'
;
var
selectUrl
=
'{% url "api-perms:my-node-assets" node_id=DEFAULT_PK %}?cache_policy=1
&all=1
'
;
var
showAssetHref
=
false
;
// Need input default true
var
actions
=
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
)
{
...
...
apps/ops/templates/ops/adhoc_history.html
View file @
367ebebf
...
...
@@ -82,7 +82,7 @@ function initTable() {
select
:
[],
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
d
=
new
Date
(
cellData
);
var
d
=
toSafeLocalDateStr
(
cellData
);
$
(
td
).
html
(
d
);
}},
{
targets
:
2
,
createdCell
:
function
(
td
,
cellData
)
{
...
...
apps/ops/templates/ops/task_adhoc.html
View file @
367ebebf
...
...
@@ -109,8 +109,8 @@ $(document).ready(function () {
}
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
)
{
var
d
=
new
Date
(
cellData
);
$
(
td
).
html
(
d
.
toLocaleString
()
)
var
d
=
toSafeLocalDateStr
(
cellData
);
$
(
td
).
html
(
d
)
}},
{
targets
:
7
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a class="btn btn-xs btn-primary m-l-xs btn-run" href="{% url '
ops
:
adhoc
-
detail
' pk=DEFAULT_PK %}">{% trans "Detail" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
...
...
apps/ops/templates/ops/task_history.html
View file @
367ebebf
...
...
@@ -88,8 +88,9 @@ function initTable() {
select
:
[],
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
d
=
new
Date
(
cellData
);
$
(
td
).
html
(
d
.
toLocaleString
());
var
d
=
toSafeLocalDateStr
(
cellData
);
$
(
td
).
html
(
d
);
}},
{
targets
:
2
,
createdCell
:
function
(
td
,
cellData
)
{
var
total
=
"<span>"
+
cellData
.
total
+
"</span>"
;
...
...
apps/perms/api/user_permission.py
View file @
367ebebf
...
...
@@ -88,13 +88,18 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, GrantAssetsMixin, ListA
def
get_queryset
(
self
):
user
=
self
.
get_object
()
query_all
=
self
.
request
.
query_params
.
get
(
"all"
,
"0"
)
==
"1"
self
.
util
=
AssetPermissionUtil
(
user
,
cache_policy
=
self
.
cache_policy
)
key
=
self
.
get_node_key
()
nodes_items
=
self
.
util
.
get_nodes_with_assets
()
assets_system_users
=
{}
if
query_all
:
k
=
"all_assets"
else
:
k
=
"assets"
for
item
in
nodes_items
:
if
item
[
"key"
]
==
key
:
assets_system_users
=
item
[
"assets"
]
assets_system_users
=
item
[
k
]
break
assets
=
[]
for
asset_id
,
system_users
in
assets_system_users
.
items
():
...
...
apps/perms/migrations/0002_auto_20171228_0025_squashed_0009_auto_20180903_1132.py
View file @
367ebebf
...
...
@@ -103,9 +103,9 @@ class Migration(migrations.Migration):
name
=
'nodes'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'granted_by_permissions'
,
to
=
'assets.Node'
,
verbose_name
=
'Nodes'
),
),
migrations
.
RunPython
(
code
=
migrate_node_permissions
,
),
#
migrations.RunPython(
#
code=migrate_node_permissions,
#
),
migrations
.
RunPython
(
code
=
migrate_system_assets_relation
,
),
...
...
apps/perms/serializers/user_permission.py
View file @
367ebebf
...
...
@@ -44,7 +44,7 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
model
=
Asset
only_fields
=
[
"id"
,
"hostname"
,
"ip"
,
"protocols"
,
"os"
,
'domain'
,
"platform"
,
"org_id"
,
"platform"
,
"
comment"
,
"
org_id"
,
]
fields
=
only_fields
+
[
'system_users_granted'
,
'system_users_join'
,
"org_name"
]
read_only_fields
=
fields
...
...
apps/perms/utils/asset_permission.py
View file @
367ebebf
...
...
@@ -203,14 +203,16 @@ class GenerateTree:
nodes
=
[]
for
key
,
values
in
nodes_with_assets_amount
.
items
():
assets
=
{
asset_id
:
self
.
assets
.
get
(
asset_id
)
for
asset_id
in
values
[
"assets"
]}
all_assets
=
{
asset_id
:
self
.
assets
.
get
(
asset_id
)
for
asset_id
in
values
[
"all_assets"
]}
nodes
.
append
({
"key"
:
key
,
"assets"
:
assets
,
"key"
:
key
,
"assets"
:
assets
,
"all_assets"
:
all_assets
,
"assets_amount"
:
values
[
"assets_amount"
]
})
# 如果返回空节点,页面构造授权资产树报错
if
not
nodes
:
nodes
.
append
({
"key"
:
const
.
EMPTY_NODE_KEY
,
"assets"
:
{},
"assets_amount"
:
0
"key"
:
const
.
EMPTY_NODE_KEY
,
"assets"
:
{},
"assets_amount"
:
0
,
"all_assets"
:
{},
})
nodes
.
sort
(
key
=
lambda
n
:
self
.
key_sort
(
n
[
"key"
]))
self
.
_nodes_with_assets
=
nodes
...
...
apps/settings/forms.py
View file @
367ebebf
...
...
@@ -40,8 +40,8 @@ class BaseForm(forms.Form):
field
=
self
.
fields
[
name
]
if
isinstance
(
field
.
widget
,
forms
.
PasswordInput
)
and
not
value
:
continue
if
value
==
getattr
(
settings
,
name
):
continue
#
if value == getattr(settings, name):
#
continue
encrypted
=
True
if
isinstance
(
field
,
FormEncryptMixin
)
else
False
try
:
...
...
apps/static/js/jumpserver.js
View file @
367ebebf
...
...
@@ -305,7 +305,6 @@ function requestApi(props) {
toastr
.
error
(
msg
);
}
if
(
typeof
props
.
error
===
'function'
)
{
console
.
log
(
jqXHR
);
return
props
.
error
(
jqXHR
.
responseText
,
jqXHR
.
status
);
}
});
...
...
@@ -610,7 +609,6 @@ jumpserver.initServerSideDataTable = function (options) {
if
(
kv
.
length
===
2
)
{
var
value
=
kv
[
1
];
value
=
value
.
replace
(
"+"
,
" "
);
console
.
log
(
value
);
search_attr
[
kv
[
0
]]
=
value
}
else
{
search_raw
.
push
(
kv
)
...
...
@@ -654,8 +652,6 @@ jumpserver.initServerSideDataTable = function (options) {
$
.
each
(
rows
,
function
(
id
,
row
)
{
table
.
selected_rows
.
push
(
row
);
if
(
row
.
id
&&
$
.
inArray
(
row
.
id
,
table
.
selected
)
===
-
1
){
console
.
log
(
table
)
console
.
log
(
table
.
selected
);
table
.
selected
.
push
(
row
.
id
)
}
})
...
...
@@ -1095,7 +1091,7 @@ function objectAttrsIsList(obj, attrs) {
function
objectAttrsIsDatetime
(
obj
,
attrs
)
{
attrs
.
forEach
(
function
(
attr
)
{
obj
[
attr
]
=
new
Date
(
obj
[
attr
]).
toISOString
(
);
obj
[
attr
]
=
toSafeDateISOStr
(
obj
[
attr
]
);
})
}
...
...
@@ -1109,21 +1105,38 @@ function objectAttrsIsBool(obj, attrs) {
})
}
function
cleanDate
(
d
)
{
if
(
typeof
d
===
'number'
){
return
d
}
for
(
var
i
=
0
;
i
<
2
;
i
++
)
{
if
(
isNaN
(
Date
.
parse
(
d
)))
{
d
=
d
.
split
(
'+'
)[
0
].
trimRight
();
}
else
{
return
d
function
cleanDateStr
(
d
)
{
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
if
(
!
isNaN
(
Date
.
parse
(
d
))){
return
d
;
}
if
(
!
isNaN
(
Number
(
d
)))
{
return
d
;
}
switch
(
i
)
{
case
0
:
d
=
d
.
replaceAll
(
'-'
,
'/'
);
break
;
case
1
:
d
=
d
.
split
(
'+'
)[
0
].
trimRight
();
break
;
}
}
return
''
return
null
;
}
function
safeDate
(
s
)
{
s
=
cleanDateStr
(
s
);
return
new
Date
(
s
)
}
function
toSafeDateISOStr
(
s
)
{
var
d
=
safeDate
(
s
);
return
d
.
toISOString
();
}
function
formatDateAsCN
(
d
)
{
d
=
cleanDate
(
d
);
var
date
=
new
Date
(
d
);
function
toSafeLocalDateStr
(
d
)
{
var
date
=
safeDate
(
d
);
var
date_s
=
date
.
toLocaleString
(
navigator
.
language
,
{
hour12
:
false
});
return
date_s
.
split
(
"/"
).
join
(
'-'
)
}
...
...
@@ -1144,17 +1157,15 @@ function getTimeUnits(u) {
"m"
:
"分"
,
"s"
:
"秒"
,
};
if
(
navigator
.
language
||
"zh-CN"
)
{
if
(
navigator
.
language
===
"zh-CN"
)
{
return
units
[
u
]
}
return
u
}
function
timeOffset
(
a
,
b
)
{
a
=
cleanDate
(
a
);
b
=
cleanDate
(
b
);
var
start
=
new
Date
(
a
);
var
end
=
new
Date
(
b
);
var
start
=
safeDate
(
a
);
var
end
=
safeDate
(
b
);
var
offset
=
(
end
-
start
)
/
1000
;
var
days
=
offset
/
3600
/
24
;
...
...
@@ -1179,7 +1190,6 @@ function readFile(ref) {
var
hasFile
=
files
&&
files
.
length
>
0
;
if
(
hasFile
)
{
var
reader
=
new
FileReader
();
//新建一个FileReader
console
.
log
(
typeof
files
[
0
]);
reader
.
readAsText
(
files
[
0
],
"UTF-8"
);
//读取文件
reader
.
onload
=
function
(
evt
){
//读取完文件之后会回来这里
ref
.
trigger
(
"onload"
,
evt
.
target
.
result
);
...
...
apps/templates/_foot_js.html
View file @
367ebebf
...
...
@@ -7,7 +7,7 @@
<script
src=
"{% static "
js
/
plugins
/
toastr
/
toastr
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
inspinia
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% url 'javascript-catalog' %}"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}?
v=
1
"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}?
v=
2
"
></script>
<script>
activeNav
();
$
(
document
).
ready
(
function
(){
...
...
apps/terminal/templates/terminal/command_list.html
View file @
367ebebf
...
...
@@ -89,14 +89,16 @@ $(document).ready(function () {
language
:
navigator
.
language
||
"en"
,
};
dateFromRef
.
datepicker
(
options
).
on
(
"changeDate"
,
function
()
{
var
date
=
new
Date
(
$
(
this
).
val
()
+
' 0:0:0'
);
var
value
=
$
(
this
).
val
()
+
' 0:0:0'
;
var
date
=
safeDate
(
value
);
var
url
=
table
.
ajax
.
url
();
url
=
setUrlParam
(
url
,
"date_from"
,
date
.
getTime
()
/
1000
);
table
.
ajax
.
url
(
url
);
table
.
ajax
.
reload
();
});
dateToRef
.
datepicker
(
options
).
on
(
"changeDate"
,
function
()
{
var
date
=
new
Date
(
$
(
this
).
val
()
+
' 23:59:59'
);
var
value
=
$
(
this
).
val
()
+
' 23:59:59'
;
var
date
=
safeDate
(
value
);
var
url
=
table
.
ajax
.
url
();
url
=
setUrlParam
(
url
,
"date_to"
,
date
.
getTime
()
/
1000
);
table
.
ajax
.
url
(
url
);
...
...
@@ -191,7 +193,7 @@ function initTable() {
$
(
td
).
html
(
data
);
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
)
{
var
data
=
formatDateAsCN
(
cellData
*
1000
);
var
data
=
toSafeLocalDateStr
(
cellData
*
1000
);
$
(
td
).
html
(
data
);
}},
],
...
...
apps/terminal/templates/terminal/session_list.html
View file @
367ebebf
...
...
@@ -104,8 +104,8 @@ var dateFrom = "{{ date_from.timestamp }}";
var
dateTo
=
"{{ date_to.timestamp }}"
;
function
initTable
()
{
dateFrom
=
new
Date
(
dateFrom
*
1000
).
toISOString
(
);
dateTo
=
new
Date
(
dateTo
*
1000
).
toISOString
(
);
dateFrom
=
toSafeDateISOStr
(
dateFrom
*
1000
);
dateTo
=
toSafeDateISOStr
(
dateTo
*
1000
);
sessionListUrl
=
setUrlParam
(
sessionListUrl
,
"date_from"
,
dateFrom
);
sessionListUrl
=
setUrlParam
(
sessionListUrl
,
"date_to"
,
dateTo
);
var
options
=
{
...
...
@@ -121,7 +121,7 @@ function initTable() {
$
(
td
).
html
(
data
);
}},
{
targets
:
9
,
createdCell
:
function
(
td
,
cellData
)
{
var
data
=
formatDateAsCN
(
cellData
);
var
data
=
toSafeLocalDateStr
(
cellData
);
$
(
td
).
html
(
data
);
}},
{
targets
:
10
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
...
...
@@ -201,9 +201,9 @@ $(document).ready(function() {
return
}
var
value
=
$
(
this
).
val
()
+
' 0:0:0'
;
var
date
=
new
Date
(
value
);
var
date
=
toSafeDateISOStr
(
value
);
var
url
=
table
.
ajax
.
url
();
url
=
setUrlParam
(
url
,
"date_from"
,
date
.
toISOString
()
);
url
=
setUrlParam
(
url
,
"date_from"
,
date
);
table
.
ajax
.
url
(
url
);
table
.
ajax
.
reload
();
});
...
...
@@ -212,9 +212,9 @@ $(document).ready(function() {
return
}
var
value
=
$
(
this
).
val
()
+
' 23:59:59'
;
var
date
=
new
Date
(
value
);
var
date
=
toSafeDateISOStr
(
value
);
var
url
=
table
.
ajax
.
url
();
url
=
setUrlParam
(
url
,
"date_to"
,
date
.
toISOString
()
);
url
=
setUrlParam
(
url
,
"date_to"
,
date
);
table
.
ajax
.
url
(
url
);
table
.
ajax
.
reload
();
});
...
...
apps/users/templates/users/user_granted_asset.html
View file @
367ebebf
...
...
@@ -33,7 +33,7 @@
{% block custom_foot_js %}
<script>
var
assetTableUrl
=
"{% url 'api-perms:user-assets' pk=object.id %}?cache_policy=1"
;
var
selectUrl
=
'{% url "api-perms:user-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1'
;
var
selectUrl
=
'{% url "api-perms:user-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1
&all=1
'
;
var
treeUrl
=
"{% url 'api-perms:user-nodes-as-tree' pk=object.id %}?&cache_policy=1"
;
$
(
document
).
ready
(
function
()
{
...
...
apps/users/templates/users/user_group_granted_asset.html
View file @
367ebebf
...
...
@@ -35,7 +35,7 @@
<script>
var
treeUrl
=
"{% url 'api-perms:user-group-nodes-as-tree' pk=object.id %}?cache_policy=1"
;
var
assetTableUrl
=
"{% url 'api-perms:user-group-assets' pk=object.id %}?cache_policy=1"
;
var
selectUrl
=
'{% url "api-perms:user-group-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1'
;
var
selectUrl
=
'{% url "api-perms:user-group-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1
&all=1
'
;
var
showAssetHref
=
true
;
// Need input default true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment