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
9e09a962
Commit
9e09a962
authored
Jan 30, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] 支持popover
parent
3e62a7f5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
63 additions
and
22 deletions
+63
-22
api.py
apps/assets/api.py
+1
-1
serializers.py
apps/assets/serializers.py
+4
-4
asset_group_list.html
apps/assets/templates/assets/asset_group_list.html
+6
-2
asset_modal_list.html
apps/assets/templates/assets/asset_modal_list.html
+0
-1
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+16
-7
jumpserver.css
apps/static/css/jumpserver.css
+5
-0
jumpserver.js
apps/static/js/jumpserver.js
+22
-2
serializers.py
apps/users/serializers.py
+3
-3
user_group_list.html
apps/users/templates/users/user_group_list.html
+6
-2
No files found.
apps/assets/api.py
View file @
9e09a962
...
...
@@ -42,7 +42,7 @@ class AssetViewSet(CustomFilterMixin, LabelFilter, BulkModelViewSet):
"""
filter_fields
=
(
"hostname"
,
"ip"
)
search_fields
=
filter_fields
ordering_fields
=
(
"hostname"
,
"ip"
,
"port"
,
"cluster"
,
"
type"
,
"env"
,
"
cpu_cores"
)
ordering_fields
=
(
"hostname"
,
"ip"
,
"port"
,
"cluster"
,
"cpu_cores"
)
queryset
=
Asset
.
objects
.
all
()
serializer_class
=
serializers
.
AssetSerializer
pagination_class
=
LimitOffsetPagination
...
...
apps/assets/serializers.py
View file @
9e09a962
...
...
@@ -12,7 +12,7 @@ class AssetGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
"""
资产组序列化数据模型
"""
assets_
amount
=
serializers
.
SerializerMethodField
()
assets_
display
=
serializers
.
SerializerMethodField
()
assets
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
Asset
.
objects
.
all
(),
required
=
False
)
...
...
@@ -20,11 +20,11 @@ class AssetGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
Meta
:
model
=
AssetGroup
list_serializer_class
=
BulkListSerializer
fields
=
[
'id'
,
'name'
,
'comment'
,
'assets_
amount
'
,
'assets'
]
fields
=
[
'id'
,
'name'
,
'comment'
,
'assets_
display
'
,
'assets'
]
@staticmethod
def
get_assets_
amount
(
obj
):
return
obj
.
assets
.
all
()
.
count
()
def
get_assets_
display
(
obj
):
return
[
asset
.
hostname
for
asset
in
obj
.
assets
.
all
()]
class
AssetUpdateSystemUserSerializer
(
serializers
.
ModelSerializer
):
...
...
apps/assets/templates/assets/asset_group_list.html
View file @
9e09a962
...
...
@@ -33,14 +33,18 @@ $(document).ready(function(){
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "assets:asset-group-detail" pk=DEFAULT_PK %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'{{ DEFAULT_PK }}'
,
rowData
.
id
));
}},
}},
{
targets
:
2
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'<a href="{% url "assets:asset-group-update" pk=DEFAULT_PK %}" class="btn btn-xs m-l-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_asset_group_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
$
(
td
).
html
(
update_btn
+
del_btn
)
}}],
ajax_url
:
'{% url "api-assets:asset-group-list" %}'
,
columns
:
[{
data
:
"id"
},
{
data
:
"name"
},
{
data
:
"assets_
amount
"
},
{
data
:
"comment"
},
{
data
:
"id"
}],
columns
:
[{
data
:
"id"
},
{
data
:
"name"
},
{
data
:
"assets_
display
"
},
{
data
:
"comment"
},
{
data
:
"id"
}],
op_html
:
$
(
'#actions'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
...
...
apps/assets/templates/assets/asset_modal_list.html
View file @
9e09a962
...
...
@@ -29,7 +29,6 @@
<td
class=
"text-center"
>
{{ asset.id }}
</td>
<td
class=
"text-center"
>
{{ asset.hostname }}
</td>
<td
class=
"text-center"
>
{{ asset.ip }}
</td>
<td
class=
"text-center"
>
{{ asset.env }}-{{ asset.type }}
</td>
</tr>
{% endfor %}
</tbody>
...
...
apps/perms/templates/perms/asset_permission_list.html
View file @
9e09a962
...
...
@@ -48,19 +48,24 @@ function initTable() {
$
(
td
).
html
(
detail_btn
.
replace
(
'{{ DEFAULT_PK }}'
,
rowData
.
id
));
}},
{
targets
:
2
,
createdCell
:
function
(
td
,
cellData
)
{
$
(
td
).
html
(
cellData
.
length
);
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
3
,
createdCell
:
function
(
td
,
cellData
)
{
$
(
td
).
html
(
cellData
.
length
);
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
)
{
$
(
td
).
html
(
cellData
.
length
);
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
$
(
td
).
html
(
cellData
.
length
);
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
)
{
$
(
td
).
html
(
cellData
.
length
);
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
7
,
createdCell
:
function
(
td
,
cellData
)
{
if
(
!
cellData
)
{
...
...
@@ -85,11 +90,15 @@ function initTable() {
],
op_html
:
$
(
'#actions'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
jumpserver
.
initDataTable
(
options
).
on
(
'daw'
,
function
()
{
$
(
'[data-toggle="popover"]'
).
popover
({
html
:
true
});
});
}
$
(
document
).
ready
(
function
(){
initTable
()
;
initTable
()
})
.
on
(
'click'
,
'.btn-del'
,
function
()
{
...
...
apps/static/css/jumpserver.css
View file @
9e09a962
...
...
@@ -340,4 +340,9 @@ div.dataTables_wrapper div.dataTables_filter {
border
:
none
;
}
.popover
{
max-width
:
100%
;
/* Max Width of the popover (depending on the container!) */
padding-left
:
20px
;
padding-right
:
20px
;
}
apps/static/js/jumpserver.js
View file @
9e09a962
...
...
@@ -310,10 +310,15 @@ jumpserver.initDataTable = function (options) {
var
$node
=
table
[
type
](
indexes
).
nodes
().
to$
();
$node
.
find
(
'input.ipt_check'
).
prop
(
'checked'
,
false
);
jumpserver
.
selected
[
$node
.
find
(
'input.ipt_check'
).
prop
(
'id'
)]
=
false
}).
on
(
'draw'
,
function
(){
}).
on
(
'draw'
,
function
(){
$
(
'#op'
).
html
(
options
.
op_html
||
''
);
$
(
'#uc'
).
html
(
options
.
uc_html
||
''
);
$
(
'[data-toggle="popover"]'
).
popover
({
html
:
true
,
placement
:
'bottom'
,
trigger
:
'hover'
,
container
:
'body'
});
});
$
(
'.ipt_check_all'
).
on
(
'click'
,
function
()
{
if
(
!
jumpserver
.
checked
)
{
...
...
@@ -512,3 +517,17 @@ function delCookie(key) {
document
.
cookie
=
key
+
'='
+
val
+
";expires"
+
expires
.
toUTCString
()
+
';path=/'
;
}
}
function
createPopover
(
dataset
,
title
,
callback
)
{
if
(
callback
!==
undefined
){
var
new_dataset
=
[];
$
.
each
(
dataset
,
function
(
index
,
value
)
{
new_dataset
.
push
(
callback
(
value
))
});
dataset
=
new_dataset
;
}
var
data_content
=
dataset
.
join
(
"</br>"
);
var
html
=
"<a data-toggle='popover' data-content='"
+
data_content
+
"'>"
+
dataset
.
length
+
"</a>"
;
return
html
;
}
\ No newline at end of file
apps/users/serializers.py
View file @
9e09a962
...
...
@@ -52,7 +52,7 @@ class UserUpdateGroupSerializer(serializers.ModelSerializer):
class
UserGroupSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
user
_amount
=
serializers
.
SerializerMethodField
()
user
s
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
UserGroup
...
...
@@ -60,8 +60,8 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
fields
=
'__all__'
@staticmethod
def
get_user
_amount
(
obj
):
return
obj
.
users
.
count
()
def
get_user
s
(
obj
):
return
[
user
.
name
for
user
in
obj
.
users
.
all
()]
class
UserGroupUpdateMemeberSerializer
(
serializers
.
ModelSerializer
):
...
...
apps/users/templates/users/user_group_list.html
View file @
9e09a962
...
...
@@ -10,7 +10,7 @@
<input
id=
""
type=
"checkbox"
class=
"ipt_check_all"
>
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'User
count
' %}
</th>
<th
class=
"text-center"
>
{% trans 'User' %}
</th>
<th
class=
"text-center"
>
{% trans 'Comment' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
</tr>
...
...
@@ -31,6 +31,10 @@ $(document).ready(function() {
var
detail_btn
=
'<a href="{% url "users:user-group-detail" pk=DEFAULT_PK %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'{{ DEFAULT_PK }}'
,
rowData
.
id
));
}},
{
targets
:
2
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
html
=
createPopover
(
cellData
);
$
(
td
).
html
(
html
);
}},
{
targets
:
3
,
createdCell
:
function
(
td
,
cellData
)
{
var
innerHtml
=
cellData
.
length
>
30
?
cellData
.
substring
(
0
,
30
)
+
'...'
:
cellData
;
$
(
td
).
html
(
'<span href="javascript:void(0);" data-toggle="tooltip" title="'
+
cellData
+
'">'
+
innerHtml
+
'</span>'
);
...
...
@@ -49,7 +53,7 @@ $(document).ready(function() {
}}
],
ajax_url
:
'{% url "api-users:user-group-list" %}'
,
columns
:
[{
data
:
function
(){
return
""
}},
{
data
:
"name"
},
{
data
:
"user
_amount
"
},
columns
:
[{
data
:
function
(){
return
""
}},
{
data
:
"name"
},
{
data
:
"user
s
"
},
{
data
:
"comment"
},
{
data
:
"id"
}],
order
:
[],
op_html
:
$
(
'#actions'
).
html
()
...
...
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