Commit 49f6ed52 authored by ibuler's avatar ibuler

Merge with master

parents 7ddfa2d2 e0179ea3
...@@ -173,21 +173,13 @@ ...@@ -173,21 +173,13 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Test system users' %}:</td> <td>{% trans 'Test system pingpong' %}:</td>
<td> <td>
<span class="pull-right"> <span class="pull-right">
<button type="button" class="btn btn-primary btn-xs" id="btn_reset_pk" style="width: 54px;">{% trans 'Test' %}</button> <button type="button" class="btn btn-primary btn-xs" id="btn_reset_pk" style="width: 54px;">{% trans 'Test' %}</button>
</span> </span>
</td> </td>
</tr> </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> </tbody>
</table> </table>
...@@ -230,41 +222,6 @@ ...@@ -230,41 +222,6 @@
</table> </table>
</div> </div>
</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> </div>
</div> </div>
......
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
keyboard: 'false', keyboard: 'false',
remote:"{% url 'assets:asset-modal-list' %}?group_id={{ group_id }}" remote:"{% url 'assets:asset-modal-list' %}?group_id={{ group_id }}"
}); });
$('#modal').on('show.bs.modal',function(){ $('#modal').on('show.bs.modal',function(){
//alert('当调用show方法时,立即触发;') //alert('当调用show方法时,立即触发;')
}); });
......
...@@ -14,26 +14,22 @@ ...@@ -14,26 +14,22 @@
<th id="th_no">id</th> <th id="th_no">id</th>
<th>资产名称</th> <th>资产名称</th>
<th>IP</th> <th>IP</th>
<th>硬件类型</th> <th>类型</th>
<th>资产组</th>
<th>部门</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for asset in asset_modal_list %} {% for asset in assets %}
{% if asset.id in all_assets %} {% if asset.id in all_assets %}
<tr name="oAssets" class="odd selected"> <tr name="oAssets" class="odd selected text-center">
<td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" checked="checked" ></td> <td class="text-center" ><input type="checkbox" name="checked" value="{{ asset.id }}" checked="checked"></td>
{% else %} {% else %}
<tr name="oAssets"> <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 %} {% endif %}
<td>{{ asset.id }}</td> <td class="text-center">{{ asset.id }}</td>
<td>{{ asset.hostname }}</td> <td class="text-center">{{ asset.hostname }}</td>
<td>{{ asset.ip }}</td> <td class="text-center">{{ asset.ip }}</td>
<td>虚拟机</td> <td class="text-center">{{ asset.env }}-{{ asset.type }}</td>
<td>网络设备</td>
<td>微信事业部</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
...@@ -61,9 +57,7 @@ $(document).ready(function(){ ...@@ -61,9 +57,7 @@ $(document).ready(function(){
{data: "id"}, {data: "id"},
{data: "hostname"}, {data: "hostname"},
{data: "ip"}, {data: "ip"},
{data: "type"}, {data: "type"}
{data: "group"},
{data: "dp"}
] ]
}); });
//将ID列隐藏 //将ID列隐藏
...@@ -77,18 +71,18 @@ $(document).ready(function(){ ...@@ -77,18 +71,18 @@ $(document).ready(function(){
}else{ }else{
$(this).addClass('selected'); $(this).addClass('selected');
this.children[0].children[0].checked=1; this.children[0].children[0].checked=1;
}; }
}); });
$('#close-btn').on('click',function(){ $('#close-btn').on('click',function(){
$('#modal').modal('hide'); $('#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(){ $('#save-btn').on('click',function(){
//alert( table.rows('.selected').data().length +' row(s) selected' ); //alert( table.rows('.selected').data().length +' row(s) selected' );
var d = table.rows('.selected').data(); var d = table.rows('.selected').data();
var size = d.length; var size = d.length;
var re = /\d+/ var re = /\d+/;
document.getElementById('add_asset').value = size; document.getElementById('add_asset').value = size;
var str= size_name; var str= size_name;
var re=/\d+/g; var re=/\d+/g;
...@@ -109,8 +103,8 @@ $(document).ready(function(){ ...@@ -109,8 +103,8 @@ $(document).ready(function(){
}); //$(document).ready }); //$(document).ready
var bCheck = 1; var bCheck = 1;
function checkAll(){ function checkAll(){
if(bCheck){ if(bCheck){
$("tr[name='oAssets']").each(function(){ $("tr[name='oAssets']").each(function(){
oCheckbox = this.children[0].children[0]; oCheckbox = this.children[0].children[0];
...@@ -127,7 +121,7 @@ $(document).ready(function(){ ...@@ -127,7 +121,7 @@ $(document).ready(function(){
}); });
document.getElementById('check_all').checked=0; document.getElementById('check_all').checked=0;
bCheck = 1; bCheck = 1;
}; }
}; }
</script> </script>
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
</div> </div>
</form> </form>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="ydxbd" id="formlists" style="display: block;"> <div class="ydxbd" id="formlists" style="display: block;">
<p id="tags_p" class="mgl-5 c02">选择需要修改属性</p> <p id="tags_p" class="mgl-5 c02">选择需要修改属性</p>
<div class="tagBtnList"> <div class="tagBtnList">
...@@ -67,7 +66,6 @@ ...@@ -67,7 +66,6 @@
<a onclick="AddForm(this,'id_comment')" 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="111" >
<input name="assets_ids" type="hidden" value="112" > <input name="assets_ids" type="hidden" value="112" >
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
...@@ -130,15 +128,15 @@ ...@@ -130,15 +128,15 @@
$('.select2').select2(); $('.select2').select2();
$("#id_tags").select2({ $("#id_tags").select2({
tags: true, tags: true,
maximumSelectionLength: 8, //最多能够选择的个数 maximumSelectionLength: 8 //最多能够选择的个数
//closeOnSelect: false //closeOnSelect: false
}); });
}; }
function AddForm(obj,id_form) { function AddForm(obj,id_form) {
var oHiddenForms = document.getElementById("ridd"); var oHiddenForms = document.getElementById("ridd");
var parentElem = document.getElementById("add_form"); var parentElem = document.getElementById("add_form");
var oH = document.getElementById(id_form); var oH = document.getElementById(id_form);
var oNew = oH.parentNode.parentNode var oNew = oH.parentNode.parentNode;
var aDiv = parentElem.getElementsByClassName('form-group'); var aDiv = parentElem.getElementsByClassName('form-group');
if(oNew.parentNode.id=='ridd') { if(oNew.parentNode.id=='ridd') {
obj.className="tagBtn2 label label-warning"; obj.className="tagBtn2 label label-warning";
...@@ -148,15 +146,15 @@ ...@@ -148,15 +146,15 @@
oHiddenForms.appendChild(oNew); oHiddenForms.appendChild(oNew);
obj.className="tagBtn2 label label-default"; obj.className="tagBtn2 label label-default";
SetSelect2(); SetSelect2();
}; }
}; }
function ChangeBtnCss(class_var){ 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++){ for (var i=0; i<changebtns.length;i++){
changebtns[i].className=class_var; changebtns[i].className=class_var;
}; }
}; }
function AddAllForm(obj) { function AddAllForm(obj) {
var oHiddenForms = document.getElementById("ridd"); var oHiddenForms = document.getElementById("ridd");
var parentElem = document.getElementById("add_form"); var parentElem = document.getElementById("add_form");
...@@ -167,18 +165,18 @@ ...@@ -167,18 +165,18 @@
if(oHidden_len == 0 || obj.innerText == "取消全选"){ if(oHidden_len == 0 || obj.innerText == "取消全选"){
for(var i=0;i<aDiv_len-1;i++){ for(var i=0;i<aDiv_len-1;i++){
oHiddenForms.appendChild(aDiv[0]); oHiddenForms.appendChild(aDiv[0]);
}; }
ChangeBtnCss("tagBtn2 label label-default"); ChangeBtnCss("tagBtn2 label label-default");
$('#changeall').text("全选"); $('#changeall').text("全选");
}else{ }else{
for(var i=0;i<oHidden_len;i++){ for(var i=0;i<oHidden_len;i++){
parentElem.insertBefore(oHiddenForms.children[0],bFormBtn); parentElem.insertBefore(oHiddenForms.children[0],bFormBtn);
}; }
ChangeBtnCss("tagBtn2 label label-warning"); ChangeBtnCss("tagBtn2 label label-warning");
$('#changeall').text("取消全选"); $('#changeall').text("取消全选");
SetSelect2(); SetSelect2();
}; }
}; }
function fsubmit(){ function fsubmit(){
...@@ -202,11 +200,11 @@ ...@@ -202,11 +200,11 @@
for(var i=0;i<m.length;i++){ for(var i=0;i<m.length;i++){
alert(m[0].value); alert(m[0].value);
oForm.appendChild(m[0]); oForm.appendChild(m[0]);
}; }
action="/assets/asset/"+assets_id[0].value+"/update"; action="/assets/asset/"+assets_id[0].value+"/update";
oForm.action=action; oForm.action=action;
oForm.submit(); oForm.submit();
}; }
} }
</script> </script>
{% endblock %} {% endblock %}
...@@ -54,10 +54,10 @@ $(document).ready(function(){ ...@@ -54,10 +54,10 @@ $(document).ready(function(){
$(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</span>'); $(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</span>');
}}, }},
{targets: 6, createdCell: function (td, cellData, rowData) { {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 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 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); 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) $(td).html(update_btn + del_btn)
}}], }}],
ajax_url: '{% url "api-assets:system-user-list" %}', ajax_url: '{% url "api-assets:system-user-list" %}',
columns: [{data: "id" }, {data: "name" }, {data: "username" }, {data: "assets_amount" }, {data: function () { return "3"}}, columns: [{data: "id" }, {data: "name" }, {data: "username" }, {data: "assets_amount" }, {data: function () { return "3"}},
......
...@@ -150,6 +150,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView): ...@@ -150,6 +150,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
group_id = self.request.GET.get('group_id') group_id = self.request.GET.get('group_id')
plain_id_lists = self.request.GET.get('plain_id_lists') plain_id_lists = self.request.GET.get('plain_id_lists')
self.s = 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): if "," in str(self.s):
self.plain_id_lists = [int(x) for x in self.s.split(',')] self.plain_id_lists = [int(x) for x in self.s.split(',')]
else: else:
...@@ -161,13 +162,19 @@ class AssetModalListView(AdminUserRequiredMixin, ListView): ...@@ -161,13 +162,19 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
else: else:
plain_id_lists = [int(self.s)] plain_id_lists = [int(self.s)]
context = { context = {
'all_assets': plain_id_lists 'all_assets': plain_id_lists,
} }
kwargs.update(context) kwargs.update(context)
if group_id: if group_id:
group = AssetGroup.objects.get(id=group_id) group = AssetGroup.objects.get(id=group_id)
context = { 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) kwargs.update(context)
return super(AssetModalListView, self).get_context_data(**kwargs) return super(AssetModalListView, self).get_context_data(**kwargs)
...@@ -253,7 +260,7 @@ class AssetGroupUpdateView(AdminUserRequiredMixin, UpdateView): ...@@ -253,7 +260,7 @@ class AssetGroupUpdateView(AdminUserRequiredMixin, UpdateView):
'action': _('Create asset group'), 'action': _('Create asset group'),
'assets_on_list': assets_all, 'assets_on_list': assets_all,
'assets_count': len(assets_all), 'assets_count': len(assets_all),
'group_id':self.object.id, 'group_id': self.object.id,
} }
kwargs.update(context) kwargs.update(context)
return super(AssetGroupUpdateView, self).get_context_data(**kwargs) return super(AssetGroupUpdateView, self).get_context_data(**kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment