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
49f6ed52
Commit
49f6ed52
authored
Mar 26, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge with master
parents
7ddfa2d2
e0179ea3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
198 deletions
+153
-198
asset_detail.html
apps/assets/templates/assets/asset_detail.html
+39
-82
asset_group_create.html
apps/assets/templates/assets/asset_group_create.html
+0
-1
asset_modal_list.html
apps/assets/templates/assets/asset_modal_list.html
+33
-39
asset_modal_update.html
apps/assets/templates/assets/asset_modal_update.html
+20
-22
system_user_list.html
apps/assets/templates/assets/system_user_list.html
+51
-51
views.py
apps/assets/views.py
+10
-3
No files found.
apps/assets/templates/assets/asset_detail.html
View file @
49f6ed52
...
...
@@ -173,21 +173,13 @@
</td>
</tr>
<tr>
<td>
{% trans 'Test system
users
' %}:
</td>
<td>
{% trans 'Test system
pingpong
' %}:
</td>
<td>
<span
class=
"pull-right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
id=
"btn_reset_pk"
style=
"width: 54px;"
>
{% trans 'Test' %}
</button>
</span>
</td>
</tr>
<tr>
<td>
{% trans 'Repush system users' %}:
</td>
<td>
<span
class=
"pull-right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
id=
"btn_reset_pk"
style=
"width: 54px;"
>
{% trans 'Push' %}
</button>
</span>
</td>
</tr>
</tbody>
</table>
...
...
@@ -230,41 +222,6 @@
</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>
</div>
</div>
</div>
...
...
@@ -343,9 +300,9 @@ $(document).ready(function () {
delete
jumpserver
.
groups_selected
[
data
.
id
]
})
})
.
on
(
'click'
,
'#is_active'
,
function
()
{
var
the_url
=
'{% url "api-assets:asset-detail" pk=asset.id %}'
;
var
checked
=
$
(
this
).
prop
(
'checked'
);
.
on
(
'click'
,
'#is_active'
,
function
()
{
var
the_url
=
'{% url "api-assets:asset-detail" pk=asset.id %}'
;
var
checked
=
$
(
this
).
prop
(
'checked'
);
var
body
=
{
'is_active'
:
checked
};
...
...
@@ -357,23 +314,23 @@ $(document).ready(function () {
success_message
:
success
});
if
(
status
==
"False"
)
{
$
(
".ibox-content > table > tbody > tr:nth-child(13) > td:last >b"
).
html
(
'True'
);
$
(
".ibox-content > table > tbody > tr:nth-child(13) > td:last >b"
).
html
(
'True'
);
}
else
{
$
(
".ibox-content > table > tbody > tr:nth-child(13) > td:last >b"
).
html
(
'False'
);
$
(
".ibox-content > table > tbody > tr:nth-child(13) > td:last >b"
).
html
(
'False'
);
}
})
.
on
(
'click'
,
'#btn_add_user_group'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
.
on
(
'click'
,
'#btn_add_user_group'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
return
false
;
}
var
groups
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'gid'
);
}).
get
();
$
.
map
(
jumpserver
.
groups_selected
,
function
(
value
,
index
)
{
groups
.
push
(
parseInt
(
index
));
$
(
'#opt_'
+
index
).
remove
();
});
updateAssetGroups
(
groups
)
var
groups
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'gid'
);
}).
get
();
$
.
map
(
jumpserver
.
groups_selected
,
function
(
value
,
index
)
{
groups
.
push
(
parseInt
(
index
));
$
(
'#opt_'
+
index
).
remove
();
});
updateAssetGroups
(
groups
)
})
.
on
(
'click'
,
'.btn_leave_group'
,
function
()
{
var
$this
=
$
(
this
);
...
...
@@ -391,33 +348,33 @@ $(document).ready(function () {
updateAssetGroups
(
groups
)
})
.
on
(
'click'
,
'.btn-system-user'
,
function
()
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
if
(
Object
.
keys
(
jumpserver
.
groups_selected
).
length
===
0
)
{
return
false
;
}
var
system_users
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'sid'
);
}).
get
();
$
.
map
(
jumpserver
.
groups_selected
,
function
(
value
,
index
)
{
system_users
.
push
(
parseInt
(
index
));
$
(
'#opt_'
+
index
).
remove
();
});
updateAssetSystem
(
system_users
)
var
system_users
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'sid'
);
}).
get
();
$
.
map
(
jumpserver
.
groups_selected
,
function
(
value
,
index
)
{
system_users
.
push
(
parseInt
(
index
));
$
(
'#opt_'
+
index
).
remove
();
});
updateAssetSystem
(
system_users
)
})
.
on
(
'click'
,
'.btn_leave_system'
,
function
()
{
var
$this
=
$
(
this
);
var
$tr
=
$this
.
closest
(
'tr'
);
var
$badge
=
$tr
.
find
(
'.bdg_group'
);
var
sid
=
$badge
.
data
(
'sid'
);
var
name
=
$badge
.
html
()
||
$badge
.
text
();
$
(
'#groups_selected'
).
append
(
'<option value="'
+
sid
+
'" id="opt_'
+
sid
+
'">'
+
name
+
'</option>'
);
$tr
.
remove
();
var
system_users
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'sid'
);
}).
get
();
updateAssetSystem
(
system_users
)
.
on
(
'click'
,
'.btn_leave_system'
,
function
()
{
var
$this
=
$
(
this
);
var
$tr
=
$this
.
closest
(
'tr'
);
var
$badge
=
$tr
.
find
(
'.bdg_group'
);
var
sid
=
$badge
.
data
(
'sid'
);
var
name
=
$badge
.
html
()
||
$badge
.
text
();
$
(
'#groups_selected'
).
append
(
'<option value="'
+
sid
+
'" id="opt_'
+
sid
+
'">'
+
name
+
'</option>'
);
$tr
.
remove
();
var
system_users
=
$
(
'.bdg_group'
).
map
(
function
()
{
return
$
(
this
).
data
(
'sid'
);
}).
get
();
updateAssetSystem
(
system_users
)
})
...
...
apps/assets/templates/assets/asset_group_create.html
View file @
49f6ed52
...
...
@@ -99,7 +99,6 @@
keyboard
:
'false'
,
remote
:
"{% url 'assets:asset-modal-list' %}?group_id={{ group_id }}"
});
$
(
'#modal'
).
on
(
'show.bs.modal'
,
function
(){
//alert('当调用show方法时,立即触发;')
});
...
...
apps/assets/templates/assets/asset_modal_list.html
View file @
49f6ed52
...
...
@@ -14,26 +14,22 @@
<th
id=
"th_no"
>
id
</th>
<th>
资产名称
</th>
<th>
IP
</th>
<th>
硬件类型
</th>
<th>
资产组
</th>
<th>
部门
</th>
<th>
类型
</th>
</tr>
</thead>
<tbody>
{% for asset in asset
_modal_list
%}
{% for asset in asset
s
%}
{% if asset.id in all_assets %}
<tr
name=
"oAssets"
class=
"odd selected"
>
<td
class=
"text-center"
><input
type=
"checkbox"
name=
"checked"
value=
"{{ asset.id }}"
checked=
"checked"
></td>
<tr
name=
"oAssets"
class=
"odd selected
text-center
"
>
<td
class=
"text-center"
><input
type=
"checkbox"
name=
"checked"
value=
"{{ asset.id }}"
checked=
"checked"
></td>
{% else %}
<tr
name=
"oAssets"
>
<td
class=
"text-center"
><input
type=
"checkbox"
name=
"checked"
value=
"{{ asset.id }}"
></td>
<td
class=
"text-center"
><input
type=
"checkbox"
name=
"checked"
value=
"{{ asset.id }}"
></td>
{% endif %}
<td>
{{ asset.id }}
</td>
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.ip }}
</td>
<td>
虚拟机
</td>
<td>
网络设备
</td>
<td>
微信事业部
</td>
<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>
...
...
@@ -61,9 +57,7 @@ $(document).ready(function(){
{
data
:
"id"
},
{
data
:
"hostname"
},
{
data
:
"ip"
},
{
data
:
"type"
},
{
data
:
"group"
},
{
data
:
"dp"
}
{
data
:
"type"
}
]
});
//将ID列隐藏
...
...
@@ -77,18 +71,18 @@ $(document).ready(function(){
}
else
{
$
(
this
).
addClass
(
'selected'
);
this
.
children
[
0
].
children
[
0
].
checked
=
1
;
}
;
}
});
$
(
'#close-btn'
).
on
(
'click'
,
function
(){
$
(
'#modal'
).
modal
(
'hide'
);
});
var
size_name
=
document
.
getElementById
(
'asset_on_count'
).
innerText
var
size_name
=
document
.
getElementById
(
'asset_on_count'
).
innerText
;
$
(
'#save-btn'
).
on
(
'click'
,
function
(){
//alert( table.rows('.selected').data().length +' row(s) selected' );
var
d
=
table
.
rows
(
'.selected'
).
data
();
var
size
=
d
.
length
;
var
re
=
/
\d
+/
var
re
=
/
\d
+/
;
document
.
getElementById
(
'add_asset'
).
value
=
size
;
var
str
=
size_name
;
var
re
=
/
\d
+/g
;
...
...
@@ -109,25 +103,25 @@ $(document).ready(function(){
});
//$(document).ready
var
bCheck
=
1
;
function
checkAll
(){
if
(
bCheck
){
$
(
"tr[name='oAssets']"
).
each
(
function
(){
oCheckbox
=
this
.
children
[
0
].
children
[
0
];
$
(
this
).
toggleClass
(
'selected'
,
true
);
oCheckbox
.
checked
=
1
;
});
document
.
getElementById
(
'check_all'
).
checked
=
1
;
bCheck
=
0
;
}
else
{
$
(
"tr[name='oAssets']"
).
each
(
function
(){
oCheckbox
=
this
.
children
[
0
].
children
[
0
];
$
(
this
).
toggleClass
(
'selected'
,
false
);
oCheckbox
.
checked
=
0
;
});
document
.
getElementById
(
'check_all'
).
checked
=
0
;
bCheck
=
1
;
};
};
var
bCheck
=
1
;
function
checkAll
(){
if
(
bCheck
){
$
(
"tr[name='oAssets']"
).
each
(
function
(){
oCheckbox
=
this
.
children
[
0
].
children
[
0
];
$
(
this
).
toggleClass
(
'selected'
,
true
);
oCheckbox
.
checked
=
1
;
});
document
.
getElementById
(
'check_all'
).
checked
=
1
;
bCheck
=
0
;
}
else
{
$
(
"tr[name='oAssets']"
).
each
(
function
(){
oCheckbox
=
this
.
children
[
0
].
children
[
0
];
$
(
this
).
toggleClass
(
'selected'
,
false
);
oCheckbox
.
checked
=
0
;
});
document
.
getElementById
(
'check_all'
).
checked
=
0
;
bCheck
=
1
;
}
}
</script>
apps/assets/templates/assets/asset_modal_update.html
View file @
49f6ed52
...
...
@@ -43,11 +43,10 @@
</div>
</form>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"ydxbd"
id=
"formlists"
style=
"display: block;"
>
<p
id=
"tags_p"
class=
"mgl-5 c02"
>
选择需要修改属性
</p>
<div
class=
"tagBtnList"
>
<a
onclick=
"AddAllForm(this)"
class=
"tagBtn2 label label-primary"
id=
"changeall"
>
全选
</a>
<div
class=
"ydxbd"
id=
"formlists"
style=
"display: block;"
>
<p
id=
"tags_p"
class=
"mgl-5 c02"
>
选择需要修改属性
</p>
<div
class=
"tagBtnList"
>
<a
onclick=
"AddAllForm(this)"
class=
"tagBtn2 label label-primary"
id=
"changeall"
>
全选
</a>
<a
onclick=
"AddForm(this,'id_port')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
端口
</a>
<a
onclick=
"AddForm(this,'id_type')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
系统类型
</a>
<a
onclick=
"AddForm(this,'id_idc')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
机房
</a>
...
...
@@ -65,9 +64,8 @@
<a
onclick=
"AddForm(this,'id_env')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
资产环境
</a>
<a
onclick=
"AddForm(this,'id_tags')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
标签
</a>
<a
onclick=
"AddForm(this,'id_comment')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
备注
</a>
</div>
</div>
</div>
</div>
<input
name=
"assets_ids"
type=
"hidden"
value=
"111"
>
<input
name=
"assets_ids"
type=
"hidden"
value=
"112"
>
<div
class=
"hr-line-dashed"
></div>
...
...
@@ -130,15 +128,15 @@
$
(
'.select2'
).
select2
();
$
(
"#id_tags"
).
select2
({
tags
:
true
,
maximumSelectionLength
:
8
,
//最多能够选择的个数
maximumSelectionLength
:
8
//最多能够选择的个数
//closeOnSelect: false
});
}
;
}
function
AddForm
(
obj
,
id_form
)
{
var
oHiddenForms
=
document
.
getElementById
(
"ridd"
);
var
parentElem
=
document
.
getElementById
(
"add_form"
);
var
oH
=
document
.
getElementById
(
id_form
);
var
oNew
=
oH
.
parentNode
.
parentNode
var
oNew
=
oH
.
parentNode
.
parentNode
;
var
aDiv
=
parentElem
.
getElementsByClassName
(
'form-group'
);
if
(
oNew
.
parentNode
.
id
==
'ridd'
)
{
obj
.
className
=
"tagBtn2 label label-warning"
;
...
...
@@ -148,15 +146,15 @@
oHiddenForms
.
appendChild
(
oNew
);
obj
.
className
=
"tagBtn2 label label-default"
;
SetSelect2
();
}
;
}
;
}
}
function
ChangeBtnCss
(
class_var
){
var
changebtns
=
$
(
"#formlists"
).
find
(
"a[name='changebtn']"
)
var
changebtns
=
$
(
"#formlists"
).
find
(
"a[name='changebtn']"
)
;
for
(
var
i
=
0
;
i
<
changebtns
.
length
;
i
++
){
changebtns
[
i
].
className
=
class_var
;
}
;
}
;
}
}
function
AddAllForm
(
obj
)
{
var
oHiddenForms
=
document
.
getElementById
(
"ridd"
);
var
parentElem
=
document
.
getElementById
(
"add_form"
);
...
...
@@ -167,18 +165,18 @@
if
(
oHidden_len
==
0
||
obj
.
innerText
==
"取消全选"
){
for
(
var
i
=
0
;
i
<
aDiv_len
-
1
;
i
++
){
oHiddenForms
.
appendChild
(
aDiv
[
0
]);
}
;
}
ChangeBtnCss
(
"tagBtn2 label label-default"
);
$
(
'#changeall'
).
text
(
"全选"
);
}
else
{
for
(
var
i
=
0
;
i
<
oHidden_len
;
i
++
){
parentElem
.
insertBefore
(
oHiddenForms
.
children
[
0
],
bFormBtn
);
}
;
}
ChangeBtnCss
(
"tagBtn2 label label-warning"
);
$
(
'#changeall'
).
text
(
"取消全选"
);
SetSelect2
();
}
;
}
;
}
}
function
fsubmit
(){
...
...
@@ -202,11 +200,11 @@
for
(
var
i
=
0
;
i
<
m
.
length
;
i
++
){
alert
(
m
[
0
].
value
);
oForm
.
appendChild
(
m
[
0
]);
}
;
}
action
=
"/assets/asset/"
+
assets_id
[
0
].
value
+
"/update"
;
oForm
.
action
=
action
;
oForm
.
submit
();
}
;
}
}
</script>
{% endblock %}
apps/assets/templates/assets/system_user_list.html
View file @
49f6ed52
...
...
@@ -26,62 +26,62 @@
</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
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>
$
(
document
).
ready
(
function
(){
var
options
=
{
ele
:
$
(
'#system_user_list_table'
),
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "assets:system-user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
}},
{
targets
:
5
,
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>'
);
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
script_btn
=
'<a href="{% url "assets:system-user-update" pk=99991937 %}" class="btn btn-xs btn-primary">{% trans "Script" %}</a>'
.
replace
(
'99991937'
,
cellData
);
var
update_btn
=
'<a href="{% url "assets:system-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
);
$
(
td
).
html
(
script_btn
+
update_btn
+
del_btn
)
}}],
ajax_url
:
'{% url "api-assets:system-user-list" %}'
,
columns
:
[{
data
:
"id"
},
{
data
:
"name"
},
{
data
:
"username"
},
{
data
:
"assets_amount"
},
{
data
:
function
()
{
return
"3"
}},
{
data
:
"comment"
},
{
data
:
"id"
}],
op_html
:
$
(
'#actions'
).
html
()
var
options
=
{
ele
:
$
(
'#system_user_list_table'
),
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "assets:system-user-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
}},
{
targets
:
5
,
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>'
);
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
{
#
var
script_btn
=
'<a href="{% url "assets:system-user-update" pk=99991937 %}" class="btn btn-xs btn-primary">{% trans "Script" %}</a>'
.
replace
(
'99991937'
,
cellData
);
#
}
var
update_btn
=
'<a href="{% url "assets:system-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
);
$
(
td
).
html
(
update_btn
+
del_btn
)
}}],
ajax_url
:
'{% url "api-assets:system-user-list" %}'
,
columns
:
[{
data
:
"id"
},
{
data
:
"name"
},
{
data
:
"username"
},
{
data
:
"assets_amount"
},
{
data
:
function
()
{
return
"3"
}},
{
data
:
"comment"
},
{
data
:
"id"
}],
op_html
:
$
(
'#actions'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
jumpserver
.
initDataTable
(
options
);
})
.
on
(
'click'
,
'.btn_admin_user_delete'
,
function
()
{
var
$this
=
$
(
this
);
var
$data_table
=
$
(
'#idc_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:system-user-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
setTimeout
(
function
()
{
var
$this
=
$
(
this
);
var
$data_table
=
$
(
'#idc_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:system-user-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
setTimeout
(
function
()
{
$data_table
.
ajax
.
reload
();
},
3000
);
})
.
on
(
'click'
,
'#btn_bulk_update'
,
function
()
{
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
$data_table
=
$
(
'#system_user_list_table'
).
DataTable
();
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
$data_table
=
$
(
'#system_user_list_table'
).
DataTable
();
var
id_list
=
[];
var
plain_id_list
=
[];
$data_table
.
rows
({
selected
:
true
}).
every
(
function
(){
...
...
@@ -118,17 +118,17 @@ $(document).ready(function(){
});
}
function
doUpdate
()
{
{
#
TODO
:
bulk
update
the
System
Users
#
}
{
#
TODO
:
bulk
update
the
System
Users
#
}
}
switch
(
action
)
{
case
'delete'
:
doDelete
();
break
;
case
'update'
:
doUpdate
();
break
;
default
:
break
;
case
'delete'
:
doDelete
();
break
;
case
'update'
:
doUpdate
();
break
;
default
:
break
;
}
})
</script>
...
...
apps/assets/views.py
View file @
49f6ed52
...
...
@@ -150,6 +150,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
group_id
=
self
.
request
.
GET
.
get
(
'group_id'
)
plain_id_lists
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
self
.
s
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
assets
=
Asset
.
objects
.
all
()
if
","
in
str
(
self
.
s
):
self
.
plain_id_lists
=
[
int
(
x
)
for
x
in
self
.
s
.
split
(
','
)]
else
:
...
...
@@ -161,13 +162,19 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
else
:
plain_id_lists
=
[
int
(
self
.
s
)]
context
=
{
'all_assets'
:
plain_id_lists
'all_assets'
:
plain_id_lists
,
}
kwargs
.
update
(
context
)
if
group_id
:
group
=
AssetGroup
.
objects
.
get
(
id
=
group_id
)
context
=
{
'all_assets'
:
[
x
.
id
for
x
in
group
.
assets
.
all
()]
'all_assets'
:
[
x
.
id
for
x
in
group
.
assets
.
all
()],
'assets'
:
assets
}
kwargs
.
update
(
context
)
else
:
context
=
{
'assets'
:
assets
}
kwargs
.
update
(
context
)
return
super
(
AssetModalListView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
@@ -253,7 +260,7 @@ class AssetGroupUpdateView(AdminUserRequiredMixin, UpdateView):
'action'
:
_
(
'Create asset group'
),
'assets_on_list'
:
assets_all
,
'assets_count'
:
len
(
assets_all
),
'group_id'
:
self
.
object
.
id
,
'group_id'
:
self
.
object
.
id
,
}
kwargs
.
update
(
context
)
return
super
(
AssetGroupUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
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