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
97fb2a4f
Commit
97fb2a4f
authored
Apr 02, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fixture] 修改index页面
parent
709552f1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
87 deletions
+24
-87
admin_user_list.html
apps/assets/templates/assets/admin_user_list.html
+3
-69
asset_list.html
apps/assets/templates/assets/asset_list.html
+1
-1
views.py
apps/assets/views.py
+9
-9
views.py
apps/jumpserver/views.py
+9
-1
_nav_user.html
apps/templates/_nav_user.html
+0
-5
config_example.py
config_example.py
+2
-2
No files found.
apps/assets/templates/assets/admin_user_list.html
View file @
97fb2a4f
...
...
@@ -15,7 +15,6 @@
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'Username' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Lost connection' %}
</th>
<th
class=
"text-center"
>
{% trans 'Comment' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
</tr>
...
...
@@ -23,18 +22,6 @@
<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>
</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 content_bottom_left %}{% endblock %}
{% block custom_foot_js %}
...
...
@@ -47,11 +34,11 @@ $(document).ready(function(){
var
detail_btn
=
'<a href="{% url "assets:admin-user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
}},
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
)
{
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
)
{
var
innerHtml
=
cellData
.
length
>
8
?
cellData
.
substring
(
0
,
24
)
+
'...'
:
cellData
;
$
(
td
).
html
(
'<a href="javascript:void(0);" data-toggle="tooltip" title="'
+
cellData
+
'">'
+
innerHtml
+
'</a>'
);
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
targets
:
5
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
#
var
script_btn
=
'<a href="{% url "assets:admin-user-update" pk=99991937 %}" class="btn btn-xs btn-primary">{% trans "Script" %}</a>'
.
replace
(
'99991937'
,
cellData
);
#
}
var
update_btn
=
'<a href="{% url "assets:admin-user-update" pk=99991937 %}" class="btn btn-xs m-l-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'99991937'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_admin_user_delete" data-uid="99991937">{% trans "Delete" %}</a>'
.
replace
(
'99991937'
,
cellData
);
...
...
@@ -59,9 +46,8 @@ $(document).ready(function(){
$
(
td
).
html
(
update_btn
+
del_btn
)
}}],
ajax_url
:
'{% url "api-assets:admin-user-list" %}'
,
columns
:
[{
data
:
function
(){
return
""
}},
{
data
:
"name"
},
{
data
:
"username"
},
{
data
:
"assets_amount"
},
{
data
:
function
()
{
return
'lost'
}
},
columns
:
[{
data
:
function
(){
return
""
}},
{
data
:
"name"
},
{
data
:
"username"
},
{
data
:
"assets_amount"
},
{
data
:
"comment"
},
{
data
:
"id"
}],
op_html
:
$
(
'#actions'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
})
...
...
@@ -76,59 +62,7 @@ $(document).ready(function(){
setTimeout
(
function
()
{
$data_table
.
ajax
.
reload
();
},
3000
);
})
.
on
(
'click'
,
'#btn_bulk_update'
,
function
()
{
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
$data_table
=
$
(
'#admin_user_list_table'
).
DataTable
();
var
id_list
=
[];
var
plain_id_list
=
[];
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
id_list
.
push
({
id
:
this
.
data
().
id
});
plain_id_list
.
push
(
this
.
data
().
id
);
});
if
(
plain_id_list
.
length
==
0
)
{
return
false
;
}
var
the_url
=
"{% url 'api-assets:admin-user-list' %}"
;
function
doDelete
()
{
swal
({
title
:
"{% trans 'Are you sure?' %}"
,
text
:
"{% trans 'This will delete the selected Admin Users !!!' %}"
,
type
:
"warning"
,
showCancelButton
:
true
,
confirmButtonColor
:
"#DD6B55"
,
confirmButtonText
:
"{% trans 'Confirm' %}"
,
closeOnConfirm
:
false
},
function
()
{
var
success
=
function
()
{
var
msg
=
"{% trans 'Admin Users Deleted.' %}"
;
swal
(
"{% trans 'Admin Users Delete' %}"
,
msg
,
"success"
);
$
(
'#admin_user_list_table'
).
DataTable
().
ajax
.
reload
();
};
var
fail
=
function
()
{
var
msg
=
"{% trans 'Admin Users Deleting failed.' %}"
;
swal
(
"{% trans 'Admin Users Delete' %}"
,
msg
,
"error"
);
};
var
url_delete
=
the_url
+
'?id__in='
+
JSON
.
stringify
(
plain_id_list
);
APIUpdateAttr
({
url
:
url_delete
,
method
:
'DELETE'
,
success
:
success
,
error
:
fail
});
$data_table
.
ajax
.
reload
();
jumpserver
.
checked
=
false
;
});
}
function
doUpdate
()
{
}
switch
(
action
)
{
case
'delete'
:
doDelete
();
break
;
case
'update'
:
doUpdate
();
break
;
default
:
break
;
}
});
</script>
{% endblock %}
...
...
apps/assets/templates/assets/asset_list.html
View file @
97fb2a4f
...
...
@@ -188,7 +188,7 @@ $(document).ready(function(){
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-assets:asset-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
console
.
log
(
the_url
);
objDelete
(
$this
,
name
,
the_url
);
obj
ect
Delete
(
$this
,
name
,
the_url
);
setTimeout
(
function
()
{
$data_table
.
ajax
.
reload
();
},
3000
);
...
...
apps/assets/views.py
View file @
97fb2a4f
...
...
@@ -22,12 +22,14 @@ from django.views.decorators.csrf import csrf_protect, csrf_exempt
from
django.utils.decorators
import
method_decorator
from
django.core.cache
import
cache
from
django.utils
import
timezone
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
common.mixins
import
JSONResponseMixin
from
common.utils
import
get_object_or_none
from
.
import
forms
from
.models
import
Asset
,
AssetGroup
,
AdminUser
,
IDC
,
SystemUser
from
.hands
import
AdminUserRequiredMixin
from
.tasks
import
update_assets_hardware_info
class
AssetListView
(
AdminUserRequiredMixin
,
TemplateView
):
...
...
@@ -44,7 +46,7 @@ class AssetListView(AdminUserRequiredMixin, TemplateView):
return
super
(
AssetListView
,
self
)
.
get_context_data
(
**
kwargs
)
class
UserAssetListView
(
TemplateView
):
class
UserAssetListView
(
LoginRequiredMixin
,
TemplateView
):
template_name
=
'assets/user_asset_list.html'
def
get_context_data
(
self
,
**
kwargs
):
...
...
@@ -64,7 +66,7 @@ class AssetCreateView(AdminUserRequiredMixin, CreateView):
success_url
=
reverse_lazy
(
'assets:asset-list'
)
def
form_valid
(
self
,
form
):
asset
=
form
.
save
()
self
.
asset
=
asset
=
form
.
save
()
asset
.
created_by
=
self
.
request
.
user
.
username
or
'Admin'
asset
.
save
()
return
super
(
AssetCreateView
,
self
)
.
form_valid
(
form
)
...
...
@@ -77,6 +79,10 @@ class AssetCreateView(AdminUserRequiredMixin, CreateView):
kwargs
.
update
(
context
)
return
super
(
AssetCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
get_success_url
(
self
):
update_assets_hardware_info
.
delay
([
self
.
asset
])
return
super
(
AssetCreateView
,
self
)
.
get_success_url
()
class
AssetModalCreateView
(
AdminUserRequiredMixin
,
ListView
):
model
=
Asset
...
...
@@ -439,16 +445,12 @@ class AdminUserDetailView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
context_object_name
=
'admin_user'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
AdminUser
.
objects
.
all
())
self
.
object
=
self
.
get_object
(
queryset
=
AdminUser
.
objects
.
all
())
return
super
(
AdminUserDetailView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
# Todo: queryset default order by connectivity, need ops support
def
get_queryset
(
self
):
return
self
.
object
.
assets
.
all
()
# def get_asset_groups(self):
# return self.object.asset_groups.all()
def
get_context_data
(
self
,
**
kwargs
):
asset_groups
=
AssetGroup
.
objects
.
all
()
assets
=
self
.
get_queryset
()
...
...
@@ -457,8 +459,6 @@ class AdminUserDetailView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
'action'
:
'Admin user detail'
,
'assets_remain'
:
[
asset
for
asset
in
Asset
.
objects
.
all
()
if
asset
not
in
assets
],
'asset_groups'
:
asset_groups
,
# 'asset_groups_remain': [asset_group for asset_group in AssetGroup.objects.all()
# if asset_group not in asset_groups]
}
kwargs
.
update
(
context
)
return
super
(
AdminUserDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
apps/jumpserver/views.py
View file @
97fb2a4f
from
django.views.generic
import
TemplateView
from
django.utils
import
timezone
from
django.db.models
import
Count
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
django.shortcuts
import
redirect
from
users.utils
import
AdminUserRequiredMixin
from
users.models
import
User
...
...
@@ -8,9 +11,14 @@ from assets.models import Asset
from
audits.models
import
ProxyLog
class
IndexView
(
AdminUser
RequiredMixin
,
TemplateView
):
class
IndexView
(
Login
RequiredMixin
,
TemplateView
):
template_name
=
'index.html'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
request
.
user
.
is_superuser
:
return
redirect
(
'assets:user-asset-list'
)
return
super
(
IndexView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
seven_days_ago
=
timezone
.
now
()
-
timezone
.
timedelta
(
days
=
7
)
month_ago
=
timezone
.
now
()
-
timezone
.
timedelta
(
days
=
30
)
...
...
apps/templates/_nav_user.html
View file @
97fb2a4f
{% load i18n %}
<li
id=
"index"
>
<a
href=
""
>
<i
class=
"fa fa-dashboard"
></i><span
class=
"nav-label"
>
{% trans 'Dashboard' %}
</span><span
class=
"label label-info pull-right"
></span>
</a>
</li>
<li
id=
"assets"
>
<a
href=
"{% url 'assets:user-asset-list' %}"
>
<i
class=
"fa fa-files-o"
></i><span
class=
"nav-label"
>
{% trans 'My assets' %}
</span><span
class=
"label label-info pull-right"
></span>
...
...
config_example.py
View file @
97fb2a4f
...
...
@@ -100,8 +100,8 @@ class DevelopmentConfig(Config):
DB_NAME
=
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
)
EMAIL_HOST
=
'smtp.exmail.qq.com'
EMAIL_PORT
=
465
EMAIL_HOST_USER
=
'a
sk
@jumpserver.org'
EMAIL_HOST_PASSWORD
=
'
xfDf4x1n
'
EMAIL_HOST_USER
=
'a@jumpserver.org'
EMAIL_HOST_PASSWORD
=
'
somepasswrd
'
EMAIL_USE_SSL
=
True
EMAIL_USE_TLS
=
False
EMAIL_SUBJECT_PREFIX
=
'[Jumpserver] '
...
...
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