Commit 49f6ed52 authored by ibuler's avatar ibuler

Merge with master

parents 7ddfa2d2 e0179ea3
......@@ -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>
......
......@@ -99,7 +99,6 @@
keyboard: 'false',
remote:"{% url 'assets:asset-modal-list' %}?group_id={{ group_id }}"
});
$('#modal').on('show.bs.modal',function(){
//alert('当调用show方法时,立即触发;')
});
......
......@@ -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 assets %}
{% 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,8 +103,8 @@ $(document).ready(function(){
}); //$(document).ready
var bCheck = 1;
function checkAll(){
var bCheck = 1;
function checkAll(){
if(bCheck){
$("tr[name='oAssets']").each(function(){
oCheckbox = this.children[0].children[0];
......@@ -127,7 +121,7 @@ $(document).ready(function(){
});
document.getElementById('check_all').checked=0;
bCheck = 1;
};
};
}
}
</script>
......@@ -43,7 +43,6 @@
</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">
......@@ -67,7 +66,6 @@
<a onclick="AddForm(this,'id_comment')" class="tagBtn2 label label-default" name="changebtn">备注</a>
</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 %}
......@@ -54,10 +54,10 @@ $(document).ready(function(){
$(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 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)
$(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"}},
......
......@@ -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)
......
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